二进制包和源码包的名称上的区别:
源码包:mysql-Version.tar.gz
二进制包:mysql-version-OS.tar.gz
MySQL 5.5.56二进制包安装
context: ]# uname -r 2.6.32-431.el6.x86_64 ]# cat /etc/redhat-release CentOS release 6.5 (Final) #删除当前系统上的mysql rpm -qa mysql yum remove mysql id mysql userdel mysql #MySQL has a dependency on the libaio library. yum install libaio #下载MySQL二进制版本 wget --no-check-certificate https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.56-linux-glibc2.5-x86_64.tar.gz groupadd mysql useradd -r -g mysql -s /bin/false mysql tar zxvf /path/to/mysql-VERSION-OS.tar.gz ln -s full-path-to-mysql-VERSION-OS mysql cd mysql chown -R mysql . chgrp -R mysql . scripts/mysql_install_db --user=mysql --basedir=/PATH/to/mysql --datadir=/PATH/to/mysql/data #修改配置文件: cp support-files/my-medium.cnf /etc/my.cnf vi /etc/my.cnf [mysqld]中添加: basedir = /PATH/mysql datadir = /PATH/mysql/data port = 3306 server_id = 1 #设置mysqld启动项 ln -s /usr/local/mysql/bin/mysql /usr/bin cp support-files/mysql.server /etc/init.d/mysqld 启动mysql: service mysqld start 修改密码: /app/mysql/bin/mysqladmin -u root password 'new-password' /app/mysql/bin/mysqladmin -u root -h node0 password 'new-password' 登录MySQL,并删除空用户 mysql -uroot -p123456 mysql> select user,host,password from mysql.user; +------+-----------+-------------------------------------------+ | user | host | password | +------+-----------+-------------------------------------------+ | root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | node0 | | | root | 127.0.0.1 | | | root | ::1 | | | | localhost | | | | node0 | | +------+-----------+-------------------------------------------+ 6 rows in set (0.00 sec) mysql> update mysql.user set password = PASSWORD('123456') WHERE user = 'root'; Query OK, 3 rows affected (0.04 sec) Rows matched: 4 Changed: 3 Warnings: 0 mysql> select user,host,password from mysql.user; +------+-----------+-------------------------------------------+ | user | host | password | +------+-----------+-------------------------------------------+ | root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | node0 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | ::1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | | localhost | | | | node0 | | +------+-----------+-------------------------------------------+ 6 rows in set (0.00 sec) mysql> DROP USER ''@localhost; Query OK, 0 rows affected (0.00 sec) mysql> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec) mysql> select user,host,password from mysql.user; +------+-----------+-------------------------------------------+ | user | host | password | +------+-----------+-------------------------------------------+ | root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | node0 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | root | ::1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | | | node0 | | +------+-----------+-------------------------------------------+ 5 rows in set (0.00 sec)
[root@node0 mysql]# scripts/mysql_install_db --user=mysql --basedir=/app/mysql --datadir=/app/mysql/data WARNING: The host 'node0' could not be looked up with resolveip. This probably means that your libc libraries are not 100 % compatible with this binary MySQL version. The MySQL daemon, mysqld, should work normally with the exception that host name resolving will not work. This means that you should use IP addresses instead of hostnames when specifying MySQL privileges ! Installing MySQL system tables... 170715 7:30:04 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 170715 7:30:04 [Note] /app/mysql/bin/mysqld (mysqld 5.5.56) starting as process 4763 ... OK Filling help tables... 170715 7:30:05 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap. 170715 7:30:05 [Note] /app/mysql/bin/mysqld (mysqld 5.5.56) starting as process 4770 ... OK To start mysqld at boot time you have to copy support-files/mysql.server to the right place for your system PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER ! To do so, start the server, then issue the following commands: /app/mysql/bin/mysqladmin -u root password 'new-password' /app/mysql/bin/mysqladmin -u root -h node0 password 'new-password' Alternatively you can run: /app/mysql/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. See the manual for more instructions. You can start the MySQL daemon with: cd /app/mysql ; /app/mysql/bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd /app/mysql/mysql-test ; perl mysql-test-run.pl Please report any problems at http://bugs.mysql.com/