1.下载MariaDB数据库
先测试是否能连接到网络: ping www.baidu.com
安装命令: 安装数据库
[root@localhost src]# yum install mariadb-server //安装mariadb数据库
[root@localhost src]# yum clean all //清空已安装文件 如果下载失败之后执行的.
安装成功提示:
数据库启动命令: 启动数据库
1. 启动命令 [root@localhost src]# systemctl start mariadb
2. 重启命令 [root@localhost src]# systemctl restart mariadb
3. 关闭命令 [root@localhost src]# systemctl stop mariadb
4. 设定开机自起 [root@localhost src]# systemctl enable mariadb
5. 关闭开机自起 [root@localhost src]# systemctl disable mariadb
数据库初始化命令: mysql_secure_installation
初始化数据库:
[root@localhost ~] mysql_secure_installation
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 #设置root密码
New password:
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数据库和对此数据库的访问权限
![20200907165746693.png](https://upload-images.jianshu.io/upload_images/26545924-ffe6f20405b4b60e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
- 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!
登录数据库: 注意!(linux系统密码是隐藏的)