mysql在linux上的安装与配置

[[email protected] /]# vi /etc/hosts
192.168.68.136 mysql-server-01

service iptables status    查看防火墙状态
chkconfig iptables off     重启后永久生效

yum -y install gcc gcc-c++

tar xzvf /usr/local/software/tar/mysql-5.6.39-linux-glibc2.12-i686.tar.gz -C /usr/local/software/
mv mysql-5.6.39-linux-glibc2.12-i686 mysql-5.6.39
cp mysql-5.6.39 /usr/local/mysql -r
groupadd mysql
useradd -r -g mysql mysql
cd /usr/local/mysql
chown -R mysql:mysql ./
./scripts/mysql_install_db --user=mysql
chown -R root:root ./
chown -R mysql:mysql data
cp support-files/mysql.server /etc/init.d/mysql
service mysql start
ps -ef|grep mysql
./bin/mysqladmin -u root password 'mysqladmin' //要先解决如下的异常,然后重启服务器
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql //一定要执行,不然不能使用mysql命令

--------------------------------------------------------------------
错误异常的解决:

[[email protected] mysql]# ./bin/mysqladmin -u root password 'mysqladmin'
./bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!

查看/tmp文件夹的确没有mysql.sock文件,

通过find命令查找

[[email protected] /]# find / -name mysql.sock
/var/lib/mysql/mysql.sock

原来安装到/var/lib/mysql/mysql.sock这个位置啦,我们需要修改my.cnf文件

[[email protected] /]# vi /etc/my.cnf

[client]
port=3306
socket=/var/lib/mysql/mysql.sock

保存之后即出,重新启动mysql。
service mysql restart
-------------------------------------------------------------------

mysql -uroot -p
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mysqladmin' WITH GRANT OPTION;
FLUSH PRIVILEGES;
service mysql restart

















猜你喜欢

转载自blog.csdn.net/ganwei793089452/article/details/79634073