2015/09/27

安裝 mariadb 並修改 root 密碼 in CentOS Linux 7

----
安裝 mariadb 並修改 root 密碼 in CentOS Linux 7
----
# 安裝 mariadb server
[root@hnamenode2 ~]# yum -y install mariadb-server mariadb-bench mariadb-libs

# 立即啟動 mariadb
[root@hnamenode2 ~]# systemctl start mariadb
# 預設開機啟動
[root@hnamenode2 ~]# systemctl enable mariadb
ln -s '/usr/lib/systemd/system/mariadb.service' '/etc/systemd/system/multi-user.target.wants/mariadb.service'
# 狀態
[root@hnamenode2 ~]# systemctl status mariadb
mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled)
   Active: active (running) since 六 2015-09-26 21:21:58 CST; 7s ago
  Process: 10071 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 9990 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 10069 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─10069 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─10226 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mys...

 9月 26 21:21:56 hnamenode2 mariadb-prepare-db-dir[9990]: The latest information about MariaDB is avail.../.
 9月 26 21:21:56 hnamenode2 mariadb-prepare-db-dir[9990]: You can find additional information about the...t:
 9月 26 21:21:56 hnamenode2 mariadb-prepare-db-dir[9990]: http://dev.mysql.com
 9月 26 21:21:56 hnamenode2 mariadb-prepare-db-dir[9990]: Support MariaDB development by buying support...DB
 9月 26 21:21:56 hnamenode2 mariadb-prepare-db-dir[9990]: Corporation Ab. You can contact us about this...m.
 9月 26 21:21:56 hnamenode2 mariadb-prepare-db-dir[9990]: Alternatively consider joining our community ...t:
 9月 26 21:21:56 hnamenode2 mariadb-prepare-db-dir[9990]: http://mariadb.com/kb/en/contributing-to-the-...t/
 9月 26 21:21:56 hnamenode2 mysqld_safe[10069]: 150926 21:21:56 mysqld_safe Logging to '/var/log/maria...g'.
 9月 26 21:21:56 hnamenode2 mysqld_safe[10069]: 150926 21:21:56 mysqld_safe Starting mysqld daemon wit...sql
 9月 26 21:21:58 hnamenode2 systemd[1]: Started MariaDB database server.
Hint: Some lines were ellipsized, use -l to show in full.

# 登入 mysql 的 root 帳號,並修改 root 密碼。
# 預設的 mysql root 密碼為空
[root@hnamenode2 html]# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
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.

# 使用 mysql DB
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

# 更新 root 使用者的密碼
MariaDB [mysql]> update user set password=PASSWORD("密碼") where User='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

# 重新載入權限表
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

# 離開 mysql
MariaDB [mysql]> exit
Bye

沒有留言: