CentOS 6.5安装MySQL 5.6.10及安全配置

注:以下所有操作均在CentOS 6.5 x86_64位系统下完成。

#准备工作#

在安装MySQL之前,请确保已经使用yum安装了各类基础组件,具体见下面的《CentOS安装LNMP环境的基础组件》。

然后创建mysql的用户组和用户,并且不允许登录权限:

# id mysql id: mysql:无此用户 # groupadd mysql # useradd -g mysql -s /sbin/nologin mysql # id mysql uid=500(mysql) gid=500(mysql) 组=500(mysql) 

#MySQL的安装#

给MySQL的安装准备目录:

# mkdir -p /data/mysql/data # chown -R mysql:mysql /data/mysql

开始源码安装MySQL:

# cd /usr/local/src # wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.10.tar.gz # tar zxf mysql-5.6.10.tar.gz # cd mysql-5.6.10 # cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6.10 -DSYSCONFDIR=/usr/local/mysql-5.6.10/etc -DMYSQL_UNIX_ADDR=/usr/local/mysql-5.6.10/tmp/mysql.sock -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DMYSQL_DATADIR=/data/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 ... CMake Warning: Manually-specified variables were not used by the project: MYSQL_USER -- Build files have been written to: /usr/local/src/mysql-5.6.10 # make && make install # mkdir -p /usr/local/mysql-5.6.10/etc # mkdir -p /usr/local/mysql-5.6.10/tmp # ln -s /usr/local/mysql-5.6.10/ /usr/local/mysql # chown -R mysql:mysql /usr/local/mysql-5.6.10 # chown -R mysql:mysql /usr/local/mysql

给当前环境添加MySQL的bin目录:

# vim /etc/profile export MYSQL_HOME=/usr/local/mysql export PATH=$PATH:$MYSQL_HOME/bin $ source /etc/profile

执行初初始化配置脚本并创建系统自带的数据库和表:

# cd /usr/local/mysql # scripts/mysql_install_db --user=mysql --datadir=/data/mysql/data ... 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: ./bin/mysqladmin -u root password 'new-password' ./bin/mysqladmin -u root -h iZ94mobdenkZ password 'new-password' Alternatively you can run: ./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 . ; ./bin/mysqld_safe & You can test the MySQL daemon with mysql-test-run.pl cd mysql-test ; perl mysql-test-run.pl Please report any problems with the ./bin/mysqlbug script! The latest information about MySQL is available on the web at http:// Support MySQL by buying support/licenses at http://shop.mysql.com WARNING: Found existing config file ./my.cnf on the system. Because this file might be in use, it was not replaced, but was used in bootstrap (unless you used --defaults-file) and when you later start the server. The new default config file was created as ./my-new.cnf, please compare it with your file and take the changes you need. WARNING: Default config file /etc/my.cnf exists on the system This file will be read by default by the MySQL server If you do not want to use this, either remove it, or use the --defaults-file argument to mysqld_safe when starting the server

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/820012d50fd56779d1b429d0052d138d.html