Installation and configuration of mysql on linux

[root@localhost /]# vi /etc/hosts
192.168.68.136 mysql-server-01

service iptables status View firewall status
chkconfig iptables off Permanent effect after restart

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' //The following exceptions must be resolved first, and then restart the server
ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql //Must execute , otherwise you cannot use the mysql command

-------------------------------------------- ------------------------
Error exception solution:

[root@localhost 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!

Check that there is no mysql.sock file in the /tmp folder, find it

through the find command

[root@localhost /]# find / -name mysql.sock
/var/lib/mysql/mysql.sock

Originally installed to /var/lib/mysql/mysql.sock, we need to modify the my.cnf file

[root@localhost /]# vi /etc/my.cnf

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

is saved, it will go out and restart 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

















Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325649824&siteId=291194637