运行yum install mariadb-server mariadb 安装 mariadb server 及 client
yum install mariadb-server mariadb
已加载插件:fastestmirror, langpacks, product-id, search-disabled-repos, subscription-
: manager
This system is not registered with Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
软件包 mariadb-server 已经被 MariaDB-server 取代,改为尝试安装 MariaDB-server-10.2.6-1.el7.centos.x86_64
软件包 mariadb 已经被 MariaDB-client 取代,改为尝试安装 MariaDB-client-10.2.6-1.el7.centos.x86_64
正在解决依赖关系
--> 正在检查事务---> 软件包 MariaDB-client.x86_64.0.10.2.6-1.el7.centos 将被 安装---> 软件包 MariaDB-server.x86_64.0.10.2.6-1.el7.centos 将被 安装--> 正在处理依赖关系 galera,它被软件包 MariaDB-server-10.2.6-1.el7.centos.x86_64 需要--> 正在检查事务---> 软件包 galera.x86_64.0.25.3.20-1.rhel7.el7.centos 将被 安装--> 正在处理依赖关系 libboost_program_options.so.1.53.0()(64bit),它被软件包 galera-25.3.20-1.rhel7.el7.centos.x86_64 需要--> 正在检查事务---> 软件包 boost-program-options.x86_64.0.1.53.0-26.el7 将被 安装--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在安装:
MariaDB-client x86_64 10.2.6-1.el7.centos mariadb 48 M
MariaDB-server x86_64 10.2.6-1.el7.centos mariadb 108 M
为依赖而安装:
boost-program-options x86_64 1.53.0-26.el7 base 156 k
galera x86_64 25.3.20-1.rhel7.el7.centos mariadb 8.0 M
事务概要
================================================================================
安装 2 软件包 (+2 依赖软件包)
总下载量:164 M
安装大小:695 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): boost-program-options-1.53.0-26.el7.x86_64.rpm | 156 kB 00:00
(2/4): MariaDB-10.2.6-centos7-x86_64-client.rpm | 48 MB 00:26
(3/4): galera-25.3.20-1.rhel7.el7.centos.x86_64.rpm | 8.0 MB 00:07
(4/4): MariaDB-10.2.6-centos7-x86_64-server.rpm | 108 MB 00:49
--------------------------------------------------------------------------------
总计 3.3 MB/s | 164 MB 00:49
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : MariaDB-client-10.2.6-1.el7.centos.x86_64 1/4
正在安装 : boost-program-options-1.53.0-26.el7.x86_64 2/4
正在安装 : galera-25.3.20-1.rhel7.el7.centos.x86_64 3/4
正在安装 : MariaDB-server-10.2.6-1.el7.centos.x86_64 4/4
chown: 无效的用户: "mysql"
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
Todo so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password''/usr/bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the optionof removing the test
databases and anonymous user created bydefault. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
验证中 : galera-25.3.20-1.rhel7.el7.centos.x86_64 1/4
验证中 : MariaDB-server-10.2.6-1.el7.centos.x86_64 2/4
验证中 : boost-program-options-1.53.0-26.el7.x86_64 3/4
验证中 : MariaDB-client-10.2.6-1.el7.centos.x86_64 4/4
已安装:
MariaDB-client.x86_64 0:10.2.6-1.el7.centos
MariaDB-server.x86_64 0:10.2.6-1.el7.centos
作为依赖被安装:
boost-program-options.x86_64 0:1.53.0-26.el7
galera.x86_64 0:25.3.20-1.rhel7.el7.centos
完毕!
开启mariadb服务。
systemctl start mariadb.service
设为开机启动:
systemctl enable mariadb.service
MariaDB Server 预设 root 密码为空密码, 要重设 root 密码,安装MariaDB时候有如下提示:
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
Todo so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password''/usr/bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
可以按照上面的提示进行密码的修改。
mysql_secure_installation可用来修改密码, 这个方法只要在指令模式输入 mysql_secure_installation, 跟著步骤回答问题就可以。以下会看看登入 mysql 修改密码。
mysql -u root
然后会看到类似 “MariaDB [(none)]>”, 输入以下指令修改:
use mysql;
updateuserset password=PASSWORD(“new_password”) whereUser=’root’;
flush privileges;
quit
上面的 new_password 请改为你想修改的密码, 这样就已经修改完成了。
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 tologinto MariaDB to secure it, we'll need the current
password forthe root user. If you've just installed MariaDB, and
you haven't setthe 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 logintothe MariaDB
root user withoutthe proper authorisation.
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
tologinto MariaDB without having to have a user account created for
them. This is intended only for testing, andto 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 atthe root password fromthe network.
Disallow root login remotely? [Y/n] Y
... 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 toit? [Y/n] Y
- 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 oftheabove steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
查看MariaDB的版本号:
mysql -V
mysql Ver 15.1 Distrib 10.2.6-MariaDB, for Linux (x86_64) using readline 5.1
cat /etc/my.cnf## This group is read both both by the client and the server# use it for options that affect everything#
[client-server]
## include all files from the config directory#
!includedir /etc/my.cnf.d
[root@localhost my.cnf.d]# ls
enable_encryption.preset mysql-clients.cnf server.cnf
把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。
mysql> grant all privileges on *.* to root@'%'identified by'password';
如果是新用户而不是root,则要先新建用户
mysql>create user 'username'@'%' identified by'password';
此时就可以进行远程连接了。