码迷,mamicode.com
首页 > 数据库 > 详细

在 CentOS 7(Linux)上安装MariaDB,搭建Mysql服务(Centos 7、mysql)

时间:2019-05-08 16:04:04      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:mariadb   直接   int   5.6   hat   tps   current   loading   ppi   

 一、安装MariaDB

安装命令

yum -y install mariadb mariadb-server

安装完成MariaDB,首先启动MariaDB、然后查看服务启动状态


[root@centos001 ~]# systemctl start mariadb [root@centos001 ~]# systemctl status mariadb ● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: active (running) since Wed 2019-05-08 15:23:10 CST; 14s ago Process: 13148 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS) Process: 13069 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS) Main PID: 13147 (mysqld_safe) CGroup: /system.slice/mariadb.service ├─13147 /bin/sh /usr/bin/mysqld_safe --basedir=/usr └─13309 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb... May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: MySQL manual for more instructions. May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: Please report any problems at http://mariadb.org/jira May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: The latest information about MariaDB is available at http://mariadb.org/. May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: You can find additional information about the MySQL part at: May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: http://dev.mysql.com May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: Consider joining MariaDB‘s strong and vibrant community: May 08 15:23:08 centos001 mariadb-prepare-db-dir[13069]: https://mariadb.org/get-involved/ May 08 15:23:08 centos001 mysqld_safe[13147]: 190508 15:23:08 mysqld_safe Logging to ‘/var/log/mariadb/mariadb.log‘. May 08 15:23:08 centos001 mysqld_safe[13147]: 190508 15:23:08 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql May 08 15:23:10 centos001 systemd[1]: Started MariaDB database server. [root@centos001 ~]#

设置开机启动

[root@centos001 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

接下来进行MariaDB的相关简单配置,首先是设置密码,会提示先输入密码

 

[root@centos001 ~]# 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] ^[[A^H^H^H
Set root password? [Y/n] y
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] n
... skipping.

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] 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!

Cleaning up...

All done! If you‘ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@centos001 ~]#

Enter current password for root (enter for none):<–初次运行直接回车

设置密码

Set root password? [Y/n] <– 是否设置root用户密码,输入y并回车或直接回车
New password: <– 设置root用户的密码
Re-enter new password: <– 再输入一次你设置的密码

Remove anonymous users? [Y/n] <– 是否删除匿名用户,回车

Disallow root login remotely? [Y/n] <–是否禁止root远程登录,回车,

Remove test database and access to it? [Y/n] <– 是否删除test数据库,回车

Reload privilege tables now? [Y/n] <– 是否重新加载权限表,回车

初始化MariaDB完成,接下来测试登录

[root@centos001 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]>

完成。

二、配置MariaDB

查看安装

[root@centos001 ~]#  rpm -qa | grep mariadb
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
mariadb-server-5.5.60-1.el7_5.x86_64

修改配置文件

vi /etc/my.cnf

 

 

我这里所有配置都默认安装,开启远程登陆权限,使用root用户操作数据就可以了,对数据编码等设置都可以使用root 权限操作的。

 

在 CentOS 7(Linux)上安装MariaDB,搭建Mysql服务(Centos 7、mysql)

标签:mariadb   直接   int   5.6   hat   tps   current   loading   ppi   

原文地址:https://www.cnblogs.com/sopcce/p/10832305.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!