# cd /usr/local/mysql/
# cp support-files/mysql.server /etc/init.d/mysqld //拷贝mysql服务脚本到系统;
# vim /etc/init.d/mysqld 找到如下内容并添加相关路径
basedir=/usr/local/mysql //mysql安装目录;
datadir=/usr/lcoal/mysql/data //mysql数据存放目录;
# chkconfig -add mysqld //添加mysql服务到系统服务;
# chkconfig --level 235 mysqld on //设置mysql开机自启动;<--优化mysql命令调用-->
修改/etc/profile文件,在文件末尾添加
# PATH=/usr/local/mysql/bin:$PATH
# export PATH
# wq! //保存
# source /etc/profile2.1.7 启动mysql服务,并设置管理员账号密码
# service mysqld start //启动MySQL数据库服务
# mysql_secure_installation //对MySQL进行安全设置(包括数据库密码以及相关的库权限设置)
<-------此处省略---------> //这里是运行后相关的提示信息
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] y (设置MySQL管理员root密码)
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] y (移除匿名用户,选择Y)
... Success!
<-------此处省略--------->
Disallow root login remotely? [Y/n] y (移除管理员远程访问权限,选择Y)
... Success!
<-------此处省略--------->
Remove test database and access to it? [Y/n] y (移除test测试数据库,选择Y)
<-------此处省略--------->
Reload privilege tables now? [Y/n] y (刷新数据库权限,选择Y)
... Success!
Cleaning up...三:测试数据库是否可以正常工作
# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 29269
Server version: 5.5.43-log Source distribution
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>看到这些提示,说明MySQL已经正常运行,MySQL环境编译安装ok!