Linux mysql.plugin_Linux下MySQL安装
博主郵箱www.zzher@foxmail.com qq:1102471911
1 //獲得以下所需的源代碼包(文末附有安裝包),并存放在/usr/local/src
2 //與mysql相關:3 boost_1_59_0.tar.gz cmake-3.6.2.tar.gz mysql-5.7.16.tar.gz4
5 //安裝cmake前的依賴包的安裝6 //檢查gcc-c++ 、ncurses-devel是否安裝,如果沒有安裝,先用yum進行安裝7
8 編譯安裝cmake工具9 cd /usr/local/src
10 tar xf cmake-3.6.2.tar.gz11 cd cmake-3.6.2
12 ./bootstrap --prefix=/usr/local/cmake13 make14 make install #如果前面沒有指定安裝目錄,則默認安裝到/usr/local/bin/cmake15
16 建立mysql組和用戶,并將mysql用戶添加到mysql組17 groupadd mysql18 useradd -g mysql mysql19 創建mysql數據文件存放的目錄20 mkdir /mydata
21 chown mysql:mysql /mydata
22 chmod o= /mydata #設置其他人沒有任何權限
23
24 編譯安裝mysql25 cd /usr/local/src
26 tar xf mysql-5.7.16.tar.gz27 cd mysql-5.7.16
28 /usr/local/cmake/bin/cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/mydata -DWITH_BOOST=/usr/local/src -DSYSCONFDIR=/etc -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_DEBUG=0 -DMYSQL_MAINTAINER_MODE=0 -DWITH_SSL:STRING=bundled -DWITH_ZLIB:STRING=bundled
29 make &&make install30
31 更改mysql安裝目錄的屬主屬組并添加mysql環境變量32 chown -R mysql:mysql /usr/local/mysql
33 vim /etc/profile.d/mysql.sh
34 文件內容是:35 export PATH=$PATH:/usr/local/mysql/bin36 執行命令:37 bash #讓新的PATH變量生效38
39 加入服務列表并設置為開機自啟40 cd /usr/local/mysql/support-files41 cp mysql.server /etc/init.d/mysqld
42 chmod +x /etc/init.d/mysqld
43 chkconfig mysqld on44
45 修改mysql的配置文件46 cat /etc/my.cnf47
48 [mysql]49 socket=/tmp/mysql.sock50
51 [mysqld]52 datadir=/mydata
53 socket=/tmp/mysql.sock54 user=mysql55 symbolic-links=0
56
57 [mysqld_safe]58 log-error=/var/log/mysqld.log
59 pid-file=/mydata/mysqld.pid60
61 初始化mysql62 mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/mydata63 說明:64 ##“-–initialize”會生成一個隨機密碼(~/.mysql_secret),而”–initialize-insecure”不會生成密碼 ##user表示指定用戶 ##basedir表示mysql的安裝路徑,datadir表示數據庫文件存放路徑
65
66 啟動mysql服務67 # service mysqld start68 查看MySQL服務的進程和端口69 # ps -ef |grep mysqld70 root 22306 1 0 12:51 pts/0 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/mydata --pid-file=/mydata/web1.deng.com.pid
71 mysql 22480 22306 12 12:51 pts/0 00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/mydata --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/mydata/web1.deng.com.pid --socket=/tmp/mysql.sock72
73 # netstat -an | grep :3306
74 tcp 0 0 :::3306 :::*LISTEN75
76 初始化MySQL數據庫的root用戶密碼77 # mysql_secure_installation78
79 Securing the MySQL server deployment.80
81 Connecting to MySQL using a blank password.82
83 VALIDATE PASSWORD PLUGIN can be used to test passwords84 and improve security. It checks the strength of password85 and allows the users to set only those passwords which are86 secure enough. Would you like to setup VALIDATE PASSWORD plugin?
87
88 Press y|Y for Yes, any other key forNo: y #需要修改密碼,所以輸入y89
90 There are three levels of password validation policy:91
92 LOW Length >= 8
93 MEDIUM Length >= 8, numeric, mixed case, and special characters94 STRONG Length >= 8, numeric, mixed case, special characters and dictionary file95
96 Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2#設置密碼復雜度為強97 Please set the password forroot here.98
99 New password:100
101 Re-enter newpassword: #輸入2次新密碼102
103 Estimated strength of the password: 100
104 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key forNo) : y105 By default, a MySQL installation has an anonymous user,106 allowing anyone to log into MySQL without having to have107 a user account created for them. This is intended only for
108 testing, and to make the installation go a bit smoother.109 You should remove them before moving into a production110 environment.111
112 Remove anonymous users? (Press y|Y for Yes, any other key forNo) : y #刪除匿名用戶113 Success.114
115
116 Normally, root should only be allowed to connect from117 'localhost'. This ensures that someone cannot guess at118 the root password from the network.119
120 Disallow root login remotely? (Press y|Y for Yes, any other key forNo) : y #禁止root遠程登錄121
122 ... skipping.123 By default, MySQL comes with a database named 'test'that124 anyone can access. This is also intended only fortesting,125 and should be removed before moving into a production126 environment.127
128
129 Remove test database and access to it? (Press y|Y for Yes, any other key forNo) : y #刪除測試數據庫130 -Dropping test database...131 Success.132
133 -Removing privileges on test database...134 Success.135
136 Reloading the privilege tables will ensure that all changes137 made so far will take effect immediately.138
139 Reload privilege tables now? (Press y|Y for Yes, any other key forNo) : y #重新加載權限表140 Success.141
142 All done!
143
144 將MySQL數據庫的動態鏈接庫共享至系統鏈接庫145 vim /etc/ld.so.conf.d/mysql.conf
146 文件內容是:147 /usr/local/mysql/lib148
149 ldconfig -v 讓系統重新讀取庫文件150
151 測試登陸MySQL數據庫152 # mysql -uroot -p153 Enter password: #輸入剛才設置的新密碼154 Welcome to the MySQL monitor. Commands end with; or \g.155 Your MySQL connection id is 5
156 Server version: 5.7.14Source distribution157
158 Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
159
160 Oracle is a registered trademark of Oracle Corporation and/or its
161 affiliates. Other names may be trademarks of their respective162 owners.163
164 Type 'help;' or '\h' for help. Type '\c'to clear the current input statement.165
166 mysql>show databases;167 +--------------------+
168 | Database |
169 +--------------------+
170 | information_schema |
171 | mysql |
172 | performance_schema |
173 | sys |
174 +--------------------+
175 4 rows in set (0.00sec)176
177 mysql>exit178 Bye
總結
以上是生活随笔為你收集整理的Linux mysql.plugin_Linux下MySQL安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: kibana java script_E
- 下一篇: stm32 I2C架构