linux 下mysql二进制文件(tar.gz)安装

二进制文件(tar.gz)安装:
先创建用户和用户组
 su - root
groupadd mysql
useradd -g mysql mysql
解压二进制文件。
gunzip -c filename | tar -xf -
复制目录/home/mysql到/usr/local;
创建mysql许可表:
linux:/usr/local/mysql #scripts/mysql_install_db --user=mysql
设置二进制所有权,使之归root所有,并属于mysql所在管理组:
linux:/usr/local/mysql # chown -R root /usr/local/mysql
linux:/usr/local/mysql # chgrp -R mysql/usr/local/mysql
将数据目录的所有权设置为mysql管理用户:
linux:/usr/local/mysql # chown -R mysql /usr/local/mysql/data
启动服务器:
linux:/usr/local/mysql # bin/mysqld_safe --user=mysql &
登入:
linux:/usr/local/mysql # bin/mysql -u mysql
mysql>show databases;
最初只有两个:test,information_schema;
以root身份登入则有四个。
运行命令bin/mysql -u root -p,此时将出现password:(要求输入密码),但默认情况下root用户没有密码,所以回车即可。此时将进入MySQL界面,当然仍然只是个命令行窗口而以。
运行命令use test,将进入test数据库
mysql>use test;
mysql> show tables
    -> ;
Empty set (0.00 sec)
建立一个地址簿数据库:
mysql> create database address;
mysql> use address;
Database changed
创建表:
mysql> create table friends (name Char(15),telphone VarChar(20),qq Char(10), address VarChar(30));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'create table friends (name Char(15),telphone VarChar(20),qq Char(10), address ' at line 1
mysql> create table friends (name Char(15),telphone VarChar(20),qq Char(10), address VarChar(30));
Query OK, 0 rows affected (0.01 sec)

新增几笔资料,并查询看看:
mysql> insert into friends values("xyf","123456","359830463","浙江");
Query OK, 1 row affected (0.00 sec)
mysql> insert into friends values
    -> (
    -> "myblue",
    -> "6743133"
    -> ,"464313113",
    -> "zhejiang");
Query OK, 1 row affected (0.00 sec)
mysql> select * from friends;
+--------+----------+-----------+----------+
| name   | telphone | qq        | address  |
+--------+----------+-----------+----------+
| xyf    | 123456   | 359830463 | 浙江   |
| myblue | 6743133  | 464313113 | zhejiang |
+--------+----------+-----------+----------+
2 rows in set (0.00 sec)
创建和修改密码:
 #在控制台上输入
linux:/usr/local/mysql # bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 18
Server version: 5.1.12-beta MySQL Community Server (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> update user set password=password('1234') where user='root';
mysql> FLUSH PRIVILEGES; 
mysql> exit
Bye
linux:/usr/local/mysql # bin/mysql -u root -p1234
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 20
Server version: 5.1.12-beta MySQL Community Server (GPL)
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql> 
 
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

唐伯虎2022

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值