shell>groupadd mysql
shell>useradd -r -g mysql -s /bin/false mysql
shell>cd /usr/local
shell>tar zxvf
shell>/path/to/mysql-VERSION-OS
.tar.gzln -s
shell>full-path-to-mysql-VERSION-OS
mysqlcd mysql
shell>mkdir mysql-files
shell>chmod 750 mysql-files
shell>chown -R mysql .
shell>chgrp -R mysql .
shell>bin/mysql_install_db --user=mysql
# MySQL 5.7.5 shell>bin/mysqld --initialize --user=mysql
# MySQL 5.7.6 and up shell>bin/mysql_ssl_rsa_setup
# MySQL 5.7.6 and up shell>chown -R root .
shell>chown -R mysql data mysql-files
shell>bin/mysqld_safe --user=mysql &
# Next command is optional shell>cp support-files/mysql.server /etc/init.d/mysql.server
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
make && make install
如果运行有问题,先启动mysqld_safe 查找问题,找到之后关闭这个程序
4. 配置以及初始化MySQL
# cd /usr/local/mysql
4.1 设置MySQL安装目录的权限
# chown -R mysql:mysql /usr/local/mysql
4.2 初始化MySQL
# scripts/mysql_install_db --user=mysql
# cp support-files/mysql.server /etc/init.d/mysqld
4.3 重新设置MySQL安装目录的权限(除data目录外,其余所有目录及文件均修改用户为root,组不变)
# chown -R root .
# chown -R mysql data
4.4 启动mysql_safe
# bin/mysqld_safe --user=mysql &
4.5 设置MySQL的root帐号密码
- 自动设置:# ./bin/mysql_secure_installation
或
- 手动置:# ./bin/mysqladmin -u root password '<PASSWORDHERE>'
刚安装好的MySql包含一个含空密码的root帐户和一个匿名帐户,这是很大的安全隐患,对于一些重要的应用我们应将安全性尽可能提高,在这里应把匿名帐户删除、 root帐户设置密码,