centos7 安裝 mariadb-10,centos7mariadb-10

來源:互聯網
上載者:User

centos7 安裝 mariadb-10,centos7mariadb-10


http://mirrors.ustc.edu.cn/mariadb/mariadb-10.0.19/source/mariadb-10.0.19.tar.gz



因為用cmake所以線安裝下這個 可以


yum install cmake



下載了tar.gz檔案解壓到指定的目錄tar -zxvf XXX.tar.gz

進入到安裝目錄

[hcr@localhostmariadb-10.0.19]$ pwd

/app/mysql/mariadb-10.0.19


//建立下使用者 分組,需要安裝的目錄,和資料庫目錄

[hcr@localhostmariadb-10.0.19]$ sudo groupadd mysql

[sudo] password forhcr:

[hcr@localhostmariadb-10.0.19]$ sudo useradd -g mysql mysql -s /bin/false

[hcr@localhostmariadb-10.0.19]$ mkdir -p /app/data/mysql

[hcr@localhostmariadb-10.0.19]$ sudo chown -R mysql:mysql /app/data/mysql/

[hcr@localhostmariadb-10.0.19]$ mkdir /app/local/mysql




cmake. -DCMAKE_INSTALL_PREFIX=/app/local/mysql-DMYSQL_DATADIR=/app/data/mysql/ -DSYSCONFDIR=/etc



這兒可能會碰到 缺少ncurses(報Curseslibrary not found異常)的問題,可以安裝下,

yum installncurses-devel 或者現在rpm 指定安裝



[hcr@localhostmariadb-10.0.19]$ make

//此處有點慢,我去坑爹阿,太長時間了等把,早知道應該選擇

[hcr@localhostmariadb-10.0.19]$ make install

//一堆的installing

[hcr@localhostmariadb-10.0.19]$ cd /app/local/mysql/

[hcr@localhostmysql]$ sudo cp support-files/my-huge.cnf /etc/my.cnf



[hcr@localhostmysql]$ sudo vi /etc/my.cnf //編輯設定檔,在[mysqld]部分增加 datadir= /app/data/mysql  //添加MariaDB資料庫路徑

datadir =/app/data/mysql

[hcr@localhostmysql]$ sudo cp support-files/my-huge.cnf /etc/my.cnf

[hcr@localhostmysql]$ sudo cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld

[hcr@localhostmysql]$ sudo chmod 755 /etc/init.d/mysqld

[hcr@localhostmysql]$ sudo chkconfig mysqld on


[hcr@localhostmysql]$ sudo vi /etc/rc.d/init.d/mysqld


這個地方預設是

basedir=

datadir=

改成

basedir =/app/local/mysql  #MariaDB程式安裝路徑
datadir= /app/data/mysql  #MariaDB資料庫存放目錄


//服務啟動

[hcr@localhostmysql]$ sudo service mysqld start

Starting MySQL.SUCCESS!


//配置到環境中

[hcr@localhostmysql]$ sudo vi /etc/profile //增加了一個環境變數

exportPATH=$PATH:/app/local/mysql/bin



到這兒重起下機器

[hcr@localhostmysql]$ sudo shutdown -r now



初始化mysqlroot密碼

[root@localhost ~]#mysql_secure_installation

NOTE: RUNNING ALLPARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS INPRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log intoMariaDB to secure it, we'll need the current

password for theroot user. If you've just installed MariaDB, and

you haven't set theroot password yet, the password will be blank,

so you should justpress enter here.

Enter currentpassword for root (enter for none):

ERROR 1045 (28000):Access denied for user 'root'@'localhost' (using password: YES)

Enter currentpassword for root (enter for none):

ERROR 1045 (28000):Access denied for user 'root'@'localhost' (using password: YES)

//初始化直接enter就好了

Enter currentpassword for root (enter for none):

OK, successfullyused password, moving on...

Setting the rootpassword ensures that nobody can log into the MariaDB

root user withoutthe proper authorisation.

Set root password?[Y/n] y

New password:

Re-enter newpassword:

Password updatedsuccessfully!

Reloading privilegetables..

... Success!

By default, aMariaDB installation has an anonymous user, allowing anyone

to log into MariaDBwithout having to have a user account created for

them. This isintended only for testing, and to make the installation

go a bit smoother. You should remove them before moving into a

productionenvironment.

Remove anonymoususers? [Y/n] y

... Success!

Normally, rootshould only be allowed to connect from 'localhost'. This

ensures that someonecannot guess at the root password from the network.

Disallow root loginremotely? [Y/n] y

... Success!

By default, MariaDBcomes with a database named 'test' that anyone can

access. This isalso intended only for testing, and should be removed

before moving into aproduction environment.

Remove test databaseand access to it? [Y/n] n

... skipping.

Reloading theprivilege tables will ensure that all changes made so far

will take effectimmediately.

Reload privilegetables now? [Y/n] y

... Success!

Cleaning up...

All done! If you'vecompleted all of the above steps, your MariaDB

installation shouldnow be secure.

Thanks for usingMariaDB!

[root@localhost ~]#




[root@localhost ~]#service mysqld restart

Shutting downMySQL.. SUCCESS!

Starting MySQL.SUCCESS!



[root@localhost~]# mysql -u root -p

Enter password:

Welcome to theMariaDB monitor. Commands end with ; or \g.

Your MariaDBconnection id is 5

Server version:10.0.19-MariaDB-log Source distribution

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 tables

-> ;

ERROR 1046 (3D000):No database selected

MariaDB [(none)]>show databases;

+--------------------+

| Database |

+--------------------+

| information_schema|

| mysql |

| performance_schema|

| test |

+--------------------+

4 rows in set (0.04sec)

MariaDB [(none)]> //建立個測試庫串連下

MariaDB [(none)]>create database r_test;

Query OK, 1 rowaffected (0.01 sec)

MariaDB [(none)]>grant all privileges on r_test.* to 'r_test'@'localhost' identifiedby 'r_test';

Query OK, 0 rowsaffected (0.00 sec)

MariaDB [(none)]>grant all privileges on r_test.* to 'r_test'@'%' identified by'r_test';

Query OK, 0 rowsaffected (0.00 sec)



用navicat串連下




安裝方式拜讀參考:

http://www.linuxidc.com/Linux/2014-11/109049.htm


相關文章

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.