centos 安装 mysql5.7.11

1 tar zvxf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz -C /usr/local/

pwd 查看当前路径 

 2 mv mysql-5.7.11-linux-glibc2.5-x86_64/ mysql 当前路径下创建mysql的文件夹

 3 mkdir mysql/data  创建数据库文件夹
 
创建用户组用户名

 groupadd mysql

useradd mysql -g mysql

cd mysql

pwd 
显示当前路径

/usr/local/usr

chown -R mysql . 给刚才设置的mysql用户授权

chgrp -R mysql .

进入bin  目录 cd /usr/local/mysql/bin

yum install libaio

执行后的文件显示开始
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirror.lzu.edu.cn
 * extras: mirror.lzu.edu.cn
 * updates: centos.ustc.edu.cn
Package libaio-0.3.107-10.el6.x86_64 already installed and latest version
Nothing to do
执行后的文件显示结束

创建用户和数据地址
./mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data

执行后的文件显示开始

2019-04-02 07:19:24 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2019-04-02 07:19:29 [WARNING] The bootstrap log isn't empty:
2019-04-02 07:19:29 [WARNING] 2019-04-02T14:19:24.712195Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2019-04-02T14:19:24.717677Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2019-04-02T14:19:24.717692Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
执行后的文件显示结束

cd /usr/local/mysql/support-files

./mysql.server start

启动报错

Starting MySQL... ERROR! The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid).
解决办法 https://blog.51cto.com/rabbit2013/1341055

启动成功

 cat /root/.mysql_secret 查看初始密码

 # Password set for user 'root@localhost' at 2019-04-02 07:19:24 
lzrsTlbwhzQf 初始密码h9Gl,iTgPPth

 cd /usr/local/mysql/bin  

 ./mysql -uroot -p:h9Gl,iTgPPth
  登录报错
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

find / -name mysql.sock 查询文件位置

[root@localhost bin]# ./mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.11

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

登录成功

重置密码

mysql> set password=password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)

设定远程登录mysql。在Linux下为了安全,默认是不允许mysql本机以外的机器访问mysql数据库服务,因此需要重新授权root。方便远程访问。


mysql> use mysql;//命令
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed


mysql> select Host,User from user;
+-----------+-----------+
| Host      | User      |
+-----------+-----------+
| localhost | mysql.sys |
| localhost | root      |
+-----------+-----------+
2 rows in set (0.00 sec)

mysql> 

mysql> GRANT ALL PRIVILEGES ON *.* TO root@'%' identified by 'root';
Query OK, 0 rows affected, 1 warning (0.01 sec)


修改开机启动,修改软连接

[centos-1@localhost ~]$ cd /usr/local/mysql/support-files/

[centos-1@localhost support-files]$ cp mysql.server /etc/init.d

cp: cannot create regular file `/etc/init.d/mysql.server': Permission denied

[centos-1@localhost support-files]$ su root
Password: 

[root@localhost support-files]# cp mysql.server /etc/init.d

[root@localhost support-files]#  cd /etc/init.d

[root@localhost init.d]# mv mysql.server mysqld

[root@localhost init.d]# cd /usr/bin

[root@localhost bin]# ln -s /usr/local/mysql/bin/mysql mysql

[root@localhost bin]# 


https://blog.csdn.net/l1028386804/article/details/46048485/


 service mysqld stop停止命令

  service mysqld start 启动命令

   service mysqld restart 重启命令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值