1. Overview of the installation
There are many ways to install MySQL, you can directly install Yum, you can install the binary installation of the source and so on. Yum installation is not recommended here, as it is not available for custom installation. Today we use the binary installation to sample, the feature is only need simple decompression, simple configuration can be used.
2. Installation Steps
(1) New MySQL account
Groupadd mysqluseradd-s/sbin/nologin-g mysql-m mysq
(2) Unzip the installation package, the installation package used here is mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz, the installation moved to the/usr/local directory, renamed to MySQL
TAR-XF MYSQL-5.6.31-LINUX-GLIBC2.5-X86_64.TAR.GZMV mysql-5.6.31-linux-glibc2.5-x86_64//usr/local/mysql
(3) Initialize the MySQL configuration file my.cnf, where the system will prompt to overwrite the file.
Cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf
(4) Initializing database files
/usr/local/mysql/scripts/mysql_install_db-basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql
The following error message appears, which is caused by missing library files, install Libaio This software, yum install Libaio
And then initialize it again, this time it's a success. A database file was generated under the data directory.
3. Configure and start MySQL
CD/USR/LOCAL/MYSQL/CP support-files/mysql.server/etc/init.d/mysqld #复制mysql的启动脚本到/etc/init.d/directory chmod a+x/et C/init.d/mysqld #增加执行权限
Then start MySQL and check the results of MySQL startup
/etc/init.d/mysqld start
Here, MySQL will start to complete.
Note: If your MySQL installation path is not/usr/local and the directory name is not MySQL, then you have to specify the MYSQ path when initializing, and/etc/init.d/mysqld configuration file inside to put/usr/local/ MySQL changes to the actual path.
4. Add MySQL to boot
echo "/etc/init.d/mysqld start" >>/etc/rc.local
5. Modify the $path variable so that the MySQL command can be used globally
echo "Export path=/usr/local/mysql/bin: $PATH" >>/etc/profile #添加mysql的执行文件路径到PATH变量里面source/etc/profile #使配置文件生效
6. Log in to MySQL test
7.MySQL Security Configuration
Set a password for the root user of MySQL
Clean up useless MySQL users and libraries
Mysql-uroot-p
Keep only [email protected] and [email protected] Users
Delete useless databases
CentOS installation using MySQL database