1. 程式人生 > >mysql 源碼安裝

mysql 源碼安裝

new 初始化 server oba without 用戶 val clu 17.

解壓軟件包,安裝cmake
[root@server1 ~]# ls
cmake-2.8.12.2-4.el6.x86_64.rpm mysql-5.7.17 mysql-boost-5.7.17.tar.gz
[root@server1 ~]# yum install -y cmake-2.8.12.2-4.el6.x86_64.rpm
先安裝依賴性

[root@server1 mysql-5.7.17]# yum install -y gcc gcc-c++
[root@server1 mysql-5.7.17]# yum install ncurses-devel bison -y
編譯

[root@server1 mysql-5.7.17]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lnmp/mysql -DMYSQL_DATADIR=/usr/local/lnmp/mysql/data -DMYSQL_UNIX_ADDR=/usr/local/lnmp/mysql/data/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_BOOST=/root/mysql-5.7.17/boost/boost_1_59_0/

[root@server1 mysql-5.7.11]# make && make install
建用戶:
[root@server1 mysql-5.7.17]# groupadd -g 27 mysql
[root@server1 mysql-5.7.17]# useradd -u 27 -g 27 -M -d /usr/local/lnmp/mysql/ mysql
[root@server1 mysql-5.7.17]# id mysql
uid=27(mysql) gid=27(mysql) 組=27(mysql)
[root@server1 mysql-5.7.17]# usermod -s /sbin/nologin mysql
[root@server1 mysql-5.7.17]# cd /usr/local/lnmp/mysql/
[root@server1 mysql]# chown mysql.mysql . -R
[root@server1 mysql]# ll
總用量 56
drwxr-xr-x 2 mysql mysql 4096 7月 28 12:12 bin
-rw-r--r-- 1 mysql mysql 17987 11月 28 2016 COPYING
drwxr-xr-x 2 mysql mysql 4096 7月 28 12:11 docs
drwxr-xr-x 3 mysql mysql 4096 7月 28 12:11 include
drwxr-xr-x 4 mysql mysql 4096 7月 28 12:12 lib
drwxr-xr-x 4 mysql mysql 4096 7月 28 12:11 man
drwxr-xr-x 10 mysql mysql 4096 7月 28 12:12 mysql-test
-rw-r--r-- 1 mysql mysql 2478 11月 28 2016 README
drwxr-xr-x 28 mysql mysql 4096 7月 28 12:12 share
drwxr-xr-x 2 mysql mysql 4096 7月 28 12:12 support-files
[root@server1 mysql]# cd
技術分享圖片
[root@server1 ~]# source .bash_profile
[root@server1 ~]# chown root . -R
[root@server1 ~]# vim /etc/my.cnf
[root@server1 ~]# cd -
/usr/local/lnmp/mysql
[root@server1 mysql]# cd support-files/
[root@server1 support-files]# cp mysql.server /etc/init.d/mysqld
[root@server1 support-files]# ll /etc/init.d/mysqld
-rwxr-xr-x 1 root root 10916 7月 28 13:47 /etc/init.d/mysqld
[root@server1 support-files]# cd ..
[root@server1 mysql]# mysqld --initialize --user=mysql

技術分享圖片
[root@server1 mysql]# chown mysql data -R
[root@server1 mysql]# ll
總用量 60
drwxr-xr-x 2 mysql mysql 4096 7月 28 12:12 bin
-rw-r--r-- 1 mysql mysql 17987 11月 28 2016 COPYING
drwxr-x--- 5 mysql mysql 4096 7月 28 13:47 data
drwxr-xr-x 2 mysql mysql 4096 7月 28 12:11 docs
drwxr-xr-x 3 mysql mysql 4096 7月 28 12:11 include
drwxr-xr-x 4 mysql mysql 4096 7月 28 12:12 lib
drwxr-xr-x 4 mysql mysql 4096 7月 28 12:11 man
drwxr-xr-x 10 mysql mysql 4096 7月 28 12:12 mysql-test
-rw-r--r-- 1 mysql mysql 2478 11月 28 2016 README
drwxr-xr-x 28 mysql mysql 4096 7月 28 12:12 share
drwxr-xr-x 2 mysql mysql 4096 7月 28 12:12 support-files
[root@server1 mysql]# /etc/init.d/mysqld start
Starting MySQL. [確定]
[root@server1 mysql]# chown root . -R
[root@server1 mysql]# chown mysql data -R
[root@server1 mysql]# ll
總用量 60
drwxr-xr-x 2 root mysql 4096 7月 28 12:12 bin
-rw-r--r-- 1 root mysql 17987 11月 28 2016 COPYING
drwxr-x--- 5 mysql mysql 4096 7月 28 13:48 data
drwxr-xr-x 2 root mysql 4096 7月 28 12:11 docs
drwxr-xr-x 3 root mysql 4096 7月 28 12:11 include
drwxr-xr-x 4 root mysql 4096 7月 28 12:12 lib
drwxr-xr-x 4 root mysql 4096 7月 28 12:11 man
drwxr-xr-x 10 root mysql 4096 7月 28 12:12 mysql-test
-rw-r--r-- 1 root mysql 2478 11月 28 2016 README
drwxr-xr-x 28 root mysql 4096 7月 28 12:12 share
drwxr-xr-x 2 root mysql 4096 7月 28 12:12 support-files
[root@server1 mysql]# mysql_secure_installation
初始化密碼:
前兩項為NO,後面yes或回車即可
[root@server1 mysql]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:

The existing password for the user account root has expired. Please set a new password.

New password:

Re-enter new password:

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: NO
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : no

... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : yes
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? (Press y|Y for Yes, any other key for No) :

... skipping.
By default, MySQL 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? (Press y|Y for Yes, any other key for No) :

... skipping.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) :

... skipping.
All done!
[root@server1 mysql]# mysql -p
mysql> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)

mysql 源碼安裝