Install MySQL 6.5 in Centos 5.6
1. Download the RPM package corresponding to Linux
Http://dev.mysql.com/downloads/mysql/5.6.html
wget http://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.33-1.el6.x86_64.rpm-bundle.tar
2. decompress the tar package
tar -xvf MySQL-5.6.33-1.el6.x86_64.rpm-bundle.tar
3. Install MySQL
rpm -ivh MySQL-server-5.6.33-1.el6.x86_64.rpm rpm -ivh MySQL-client-5.6.33-1.el6.x86_64.rpm rpm -ivh MySQL-devel-5.6.33-1.el6.x86_64.rpm
If:
error: Failed dependencies: libaio.so.1()(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64 libaio.so.1(LIBAIO_0.1)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64 libaio.so.1(LIBAIO_0.4)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
Download libaio
yum install libaio
If:
error: Failed dependencies: libnuma.so.1()(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64 libnuma.so.1(libnuma_1.1)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64 libnuma.so.1(libnuma_1.2)(64bit) is needed by MySQL-server-5.6.33-1.el6.x86_64
Download numactl
yum install numactl
4. initialize MySQL and set the password
/usr/bin/mysql_install_dbservice mysql start
If the startup fails, the directory where the data block is located does not have the permission.
Cat/root/. mysql_secret # view the root account PASSWORD mysql> set password = PASSWORD ('20140901'); mysql> exit
If the. mysql_secret file does not exist, stop MySQL and set the password in safe mode.
service mysql stopmysqld_safe --skip-grant-tables&mysql -u root mysqlmysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';mysql> FLUSH PRIVILEGES;
5. Allow Remote Login
mysql> use mysql;mysql> select host,user,password from user;mysql> update user set host='%' where user='root' and host='localhost';mysql> flush privileges;mysql> exit
6. Set auto-start upon startup
chkconfig mysql onchkconfig --list | grep mysqlmysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
7. default installation location of MySQL
/Var/lib/mysql/# Database directory/usr/share/mysql # configuration file directory/usr/bin # related command directory/etc/init. d/mysql # Start script
8. Common commands
1. Use a client tool to connect to the database
mysql -u root -p
2. view the databases contained in the MySQL server
mysql>SHOW DATABASES;
3. View data table information in the database
mysql>SHOW TABLES;
4. Switch Database
mysql>USE mysql;
5. Create a new database
Mysql> create database name;
6. Create a new data table
Mysql> create table Name (field definition)
7. delete a data table
Mysql> drop table database name. TABLE Name;
8. delete a database
Mysql> drop database Name
9. Back up the entire database
mysqldump -u root -p auth > mysql-auth.sql
10. Back up the user table in MYSQL.
mysqldump -u root -p mysql user > mysql.host-user.sql
11. Back up all databases on the MYSQL server
mysqldump -u root -p -all-databases > mysql-all.sql
12. Restore the database
Mysql-u root-p [database name] <mysql-all. SQL
13. Grant User Permissions
GRANT permission list ON database name. Table name TO user name @ Source Address [identified by 'Password'] grant select on mysql. user TO daxiong @ 'localhost' identified by '123 ';