centos7.3二進位安裝mariadb

來源:互聯網
上載者:User

標籤:linux


centos7.3二進位安裝mariadb.10.2.8


1.確認沒有maraiadb*

rpm -qa mariadb*查看無包即可,若有,用yum remove卸載


2.useradd -d /app/mysqldb -r -m -s /sbin/nologin mysql

getent passwd mysql

建議放在邏輯卷上,資料庫會不斷變大,不能擴充的分區後期處理起來就麻煩多了。


3. tar xf mariadb-VERSION-linux-x86_64.tar.gz -C /usr/local

cd /usr/local

ln -sv mariadb-10.2.8-linux-x86_64 mysql v顯示過程


4.準備設定檔

cd /usr/local/mysql

ls support-files/

mkdir /etc/mysql

cp /usr/local/mysqlsupport-files/my-huge.cnf /etc/mysql/my.cnf

vim /etc/mysql/my.cnf

[mysqld]

datadir = /app/mysqldb 必須加

innodb_file_per_table = on 每表為一獨立檔案

skip_name_resolve = on 效能最佳化,禁止主機名稱解析


5../scripts/mysql_install_db --user=mysql --datadir=/app/mysqldb 運行指令碼,建立系統資料庫

ls /app/mysqldb 有東西了

(可能有報錯,根據報錯提醒,逐一排錯)

因為是二進位編譯,有些設定檔的位置是設定好的,這點需注意。

[[email protected] mysql]# ./scripts/mysql_install_db --datadir=/app/mysqldb --user=mysqlInstalling MariaDB/MySQL system tables in ‘/app/mysqldb‘ ...2017-10-11 20:08:53 140592457275200 [Warning] ‘THREAD_CONCURRENCY‘ is deprecated and will be removed in a future release.2017-10-11 20:08:55 140592457275200 [ERROR] ./bin/mysqld: unknown variable ‘datedir=/app/mysqldb‘2017-10-11 20:08:55 140592457275200 [ERROR] Aborting


6.準備服務指令碼,並啟動服務

cp support-files/mysql.server /etc/init.d/mysqld

chkconfig --list mysqld

chkconfig --add mysqld

service mysqld start

下面是服務不能啟動的情況

[[email protected] mysql]# service mysqld startStarting mysqld (via systemctl):  Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.                                                           [FAILED][[email protected] mysql]# systemctl status mysqld.service -l● mysqld.service - LSB: start and stop MySQL   Loaded: loaded (/etc/rc.d/init.d/mysqld; bad; vendor preset: disabled)   Active: failed (Result: exit-code) since Wed 2017-10-11 20:20:27 CST; 3min 32s ago     Docs: man:systemd-sysv-generator(8)  Process: 10519 ExecStart=/etc/rc.d/init.d/mysqld start (code=exited, status=1/FAILURE)Oct 11 20:20:26 centos7.magedu.com systemd[1]: Starting LSB: start and stop MySQL...Oct 11 20:20:26 centos7.magedu.com mysqld[10519]: Starting MySQL.171011 20:20:26 mysqld_safe Logging to ‘/var/log/mariadb/mariadb.log‘.Oct 11 20:20:26 centos7.magedu.com mysqld[10519]: 171011 20:20:26 mysqld_safe Starting mysqld daemon with databases from /app/mysqldbOct 11 20:20:26 centos7.magedu.com mysqld[10519]: [133B blob data]Oct 11 20:20:27 centos7.magedu.com mysqld[10519]: ERROR!Oct 11 20:20:27 centos7.magedu.com systemd[1]: mysqld.service: control process exited, code=exited status=1Oct 11 20:20:27 centos7.magedu.com systemd[1]: Failed to start LSB: start and stop MySQL.Oct 11 20:20:27 centos7.magedu.com systemd[1]: Unit mysqld.service entered failed state.Oct 11 20:20:27 centos7.magedu.com systemd[1]: mysqld.service failed.

可以看到缺少了記錄檔,記錄檔對於mysql資料庫還是很重要的。有時出現任務進行一半意外中斷的情況,日誌可以快速排錯。接下來我們建立記錄檔。注意許可權。許可權不對會導致服務無法啟動。

touch /var/log/mariadb/mariadb.log

chown mysql /var/log/mariadb/mariadb.log

chown mysql /var/log/mariadb

service mysqld start 


7.安全初始化環境配置

主要包括PATH環境變數及安全環境。

[[email protected] mysql]# vim /etc/profile.d/mysql.sh

PATH=/usr/local/mysql/bin/:$PATH

可以同時開一個終端測試.

A:

[[email protected] bin]# cd /usr/local/mysql/bin[[email protected] bin]# ./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 currentpassword for the root user.  If you‘ve just installed MariaDB, andyou 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):

B:查看當前登入使用者

[[email protected] ~]# mysqlWelcome to the MariaDB monitor.  Commands end with ; or \g.Your MariaDB connection id is 10Server version: 10.2.8-MariaDB-log MariaDB ServerCopyright (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)]> select user();+----------------+| user()         |+----------------+| [email protected] |+----------------+1 row in set (0.00 sec)

A:

[[email protected] bin]# ./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 currentpassword for the root user.  If you‘ve just installed MariaDB, andyou 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 MariaDBroot user without the proper authorisation.Set root password? [Y/n] yNew password: Re-enter new password: Password updated successfully!Reloading privilege tables.. ... Success!By default, a MariaDB installation has an anonymous user, allowing anyoneto log into MariaDB without having to have a user account created forthem.  This is intended only for testing, and to make the installationgo a bit smoother.  You should remove them before moving into aproduction environment.Remove anonymous users? [Y/n]

B:

[[email protected] ~]# mysqlERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)

設定完成後再以root身份登入就要執行mysql -uroot -p命令了。



本文出自 “RightNow” 部落格,請務必保留此出處http://amelie.blog.51cto.com/12850951/1971534

centos7.3二進位安裝mariadb

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.