============================================================================================================================================================================================================================================ Package 架构 版本 源 大小 ============================================================================================================================================================================================================================================ 正在安装: MariaDB-client x86_64 10.2.11-1.el7.centos mariadb 48 M MariaDB-server x86_64 10.2.11-1.el7.centos mariadb 110 M 为依赖而安装: MariaDB-common x86_64 10.2.11-1.el7.centos mariadb 154 k MariaDB-compat x86_64 10.2.11-1.el7.centos mariadb 2.8 M boost-program-options x86_64 1.53.0-27.el7 base 156 k galera x86_64 25.3.22-1.rhel7.el7.centos mariadb 8.0 M perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k perl-DBI x86_64 1.627-4.el7 base 802 k perl-IO-Compress noarch 2.061-2.el7 base 260 k perl-Net-Daemon noarch 0.48-5.el7 base 51 k perl-PlRPC noarch 0.2020-14.el7 base 36 k
[root@hadoop01 home]# mysql -uroot Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 10.2.11-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
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): #输入当前密码,一般没设置直接回车 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 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密码,输入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.
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] #是否删除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.
All done! If you've completed all of the above steps, your MariaDB installation should now be secure.
Thanks for using MariaDB!
测试登录
1 2 3 4 5 6 7 8 9 10 11
[root@hadoop01 home]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 22 Server version: 10.2.11-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
7.配置MariaDB数据库字符集
1 2 3 4
[root@hadoop01 home]# cd /etc/my.cnf.d/ [root@hadoop01 my.cnf.d]# ls enable_encryption.preset mysql-clients.cnf server.cnf [root@hadoop01 my.cnf.d]# vim server.cnf
[root@hadoop01 my.cnf.d]# systemctl restart mariadb [root@hadoop01 my.cnf.d]# mysql -uroot -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 9 Server version: 10.2.11-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.