虚拟机中我们可能会使用到MySQL数据库,那么如何安装环境呢~
小编废了九牛二虎之力安装好了,所以写出来给你们~
不过切记!下面的一切操作要在root下完成吖!
1.安装 mariadb 服务
# yum install -y mariadb-server


不过经过测试第一个步骤已经顺便安装好了2,3,如果你执行完第一个步骤,也是如图所示,那么可以跳过2,3啦~
2.安装 mariadb 命令行客户端
# yum install -y mariadb
3.安装 mariadb C library
# yum install -y mariadb-libs
4.安装 mariadb 开发包
# yum install -y mariadb-devel


5.更改 /etc/my.cnf.d 文件
# cd /etc/my.cnf.d
里面有三个文件

①编辑client.cnf文件,[client] 下加一行配置
default-character-set=utf8
最终内容:

②编辑mysql-clients.cnf文件,[mysql] 下加一行配置
default-character-set=utf8
最终内容:

③编辑server.cnf 文件,[mysqld] 下加配置
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
sql-mode = TRADITIONAL
最终内容:

6.启动服务
# systemctl start mariadb
7.设置服务开启自启动
# systemctl enable mariadb

8.查看服务状态
# systemctl enable mariadb

9.测试连接----使用命令行客户端尝试连接
# mysql -uroot
如图所示就是连接成功

10.查看 mariadb 版本号

11.查看字符集配置

使用完成用Ctrl+D或者quit退出!
12.设置密码
[root@bogon my.cnf.d ~]# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, 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 MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y
New password: 输入要为root用户设置的数据库密码。
Re-enter new password: 重复再输入一次密码。
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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] y(禁止root用户从远程登录)
... Success!
By default, MariaDB 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] y(删除test数据库并取消对其的访问权限)
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y(刷新授权表,让初始化后的设定立即生效)
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
786



被折叠的 条评论
为什么被折叠?



