一、环境说明:
2. 安装编译必须的包
编译时间是机器而定,我的有20多分钟的样子。
安装完成后要给根目录指定为mysql用户和组,也可以在这时候进行mysql用户和组的创建工作:
安装完成的MySQL根目录如下:
可以看到已经创建一个默认的配置文件my.cnf。
四、MySQL初始化
执行初始化脚本来创建数据库:
创建MySQL服务并启动:
接下来就是配置数据库了,在新版的MySQL安装过程中提供了一个脚本用于自动完成数据库使用前的配置工作,这个脚本位于/usr/local/mysql/bin/mysql_secure_installation,它会完成以下任务:
1.指定root用户密码(默认是没有密码的)
2.删除匿名用户
3.设置root用户的远程访问(对应的要在防火墙中开启3306端口)
4.是否删除测试数据库
5.重载权限表
这里建议使用这个脚本,执行过程如下:
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we\'ll need the current
password for the root user. If you\'ve just installed MySQL, and
you haven\'t set the root password yet, the password will be blank,
so you should just press enter here.
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
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from \'localhost\'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] n
... skipping.
By default, MySQL comes with a database named \'test\' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] n
... skipping.
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
All done! If you\'ve completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
本文地址:https://www.stayed.cn/item/9091
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我