Linux 7.0 安裝 mariadb 數據庫及初始化,創建數據庫,創建用戶
[root@foundation0 ~]# yum install mariadb-server.x86_64 -y
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
--> Processing Dependency: mariadb(x86-64) = 1:5.5.44-2.el7 for package: 1:mariadb-server-5.5.44-2.el7.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.44-2.el7.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.023-5.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================
============================================================================================================================================
Installing:
mariadb-server x86_64 1:5.5.44-2.el7 rhel-dvd 11 M
Installing for dependencies:
mariadb x86_64 1:5.5.44-2.el7 rhel-dvd 9.0 M
perl-DBD-MySQL x86_64 4.023-5.el7 rhel-dvd 140 k
Transaction Summary
============================================================================================================================================
Install 1 Package (+2 Dependent packages)
Total download size: 20 M
Installed size: 104 M
Downloading packages:
--------------------------------------------------------------------------------------------------------------------------------------------
Total 54 MB/s | 20 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : perl-DBD-MySQL-4.023-5.el7.x86_64 1/3
Installing : 1:mariadb-5.5.44-2.el7.x86_64 2/3
Installing : 1:mariadb-server-5.5.44-2.el7.x86_64 3/3
Verifying : 1:mariadb-5.5.44-2.el7.x86_64 1/3
Verifying : perl-DBD-MySQL-4.023-5.el7.x86_64 2/3
Verifying : 1:mariadb-server-5.5.44-2.el7.x86_64 3/3
Installed:
mariadb-server.x86_64 1:5.5.44-2.el7
Dependency Installed:
mariadb.x86_64 1:5.5.44-2.el7 perl-DBD-MySQL.x86_64 0:4.023-5.el7
Complete!
[root@foundation0 ~]# systemctl start mariadb.service
[root@foundation0 ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@foundation0 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-03-24 16:21:08 CST; 2min 5s ago
Main PID: 7103 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─7103 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─7260 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/m...
Mar 24 16:21:06 foundation0.ilt.example.com mariadb-prepare-db-dir[6950]: 190324 16:21:06 [Note] /usr/libexec/mysqld (mysqld 5.5.44-M... ...
Mar 24 16:21:06 foundation0.ilt.example.com mariadb-prepare-db-dir[6950]: OK
Mar 24 16:21:06 foundation0.ilt.example.com mariadb-prepare-db-dir[6950]: Filling help tables...
Mar 24 16:21:06 foundation0.ilt.example.com mariadb-prepare-db-dir[6950]: 190324 16:21:06 [Note] /usr/libexec/mysqld (mysqld 5.5.44-M... ...
Mar 24 16:21:06 foundation0.ilt.example.com mariadb-prepare-db-dir[6950]: OK
Mar 24 16:21:06 foundation0.ilt.example.com mariadb-prepare-db-dir[6950]: To start mysqld at boot time you have to copy
Mar 24 16:21:06 foundation0.ilt.example.com mysqld_safe[7103]: 190324 16:21:06 mysqld_safe Logging to ‘/var/log/mariadb/mariadb.log‘.
Mar 24 16:21:06 foundation0.ilt.example.com mysqld_safe[7103]: 190324 16:21:06 mysqld_safe Starting mysqld daemon with databases fro...mysql
Mar 24 16:21:08 foundation0.ilt.example.com systemd[1]: Started MariaDB database server.
Mar 24 16:22:45 foundation0.ilt.example.com systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@foundation0 ~]# 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]
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]
... 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]
... 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]
- 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]
... 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@foundation0 ~]#
[root@foundation0 ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.44-MariaDB MariaDB Server
Copyright (c) 2000, 2015, 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 |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> create database netbank;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| netbank |
| performance_schema |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> use netbank;
Database changed
MariaDB [netbank]> grant select,insert,update,drop on netbank.* to xiejiaohui@localhost identified by "redhat";
Query OK, 0 rows affected (0.00 sec)
MariaDB [netbank]> exit;
Bye
[root@foundation0 ~]# mysql -uxiejiaohui -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 5.5.44-MariaDB MariaDB Server
Copyright (c) 2000, 2015, 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 |
| netbank |
+--------------------+
2 rows in set (0.00 sec)
MariaDB [(none)]>
Linux 7.0 安裝 mariadb 數據庫及初始化,創建數據庫,創建用戶