国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

Linux下mysql源碼安裝筆記

2024-07-24 13:10:49
字體:
來源:轉載
供稿:網友

1.假設已經有mysql-5.5.10.tar.gz以及cmake-2.8.4.tar.gz兩個源文件

(1)先安裝cmake(mysql5.5以后是通過cmake來編譯的)

[root@ rhel5 local]#tar -zxv -f cmake-2.8.4.tar.gz[root@ rhel5 local]#cd cmake-2.8.4[root@ rhel5 cmake-2.8.4]#./configure[root@ rhel5 cmake-2.8.4]#make[root@ rhel5 cmake-2.8.4]#make install

(2)創建mysql的安裝目錄及數據庫存放目錄

[root@ rhel5~]#mkdir -p /usr/local/mysql         //安裝mysql [root@ rhel5~]#mkdir -p /usr/local/mysql/data      //存放數據庫

(3)創建mysql用戶及用戶組

[root@ rhel5~]groupadd mysql[root@ rhel5~]useradd -r -g mysql mysql

(4)安裝mysql

[root@ rhel5 local]#tar -zxv -f mysql-5.5.10.tar.gz[root@ rhel5 local]#cd mysql-5.5.10[root@ rhel5 mysql-5.5.10]#cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/usr/local/mysql/data-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1[root@ rhel5 mysql-5.5.10]#make[root@ rhel5 mysql-5.5.10]#make install

參數說明:

-DCMAKE_INSTALL_PREFIX=/usr/local/mysql        //安裝目錄

-DINSTALL_DATADIR=/usr/local/mysql/data         //數據庫存放目錄

-DDEFAULT_CHARSET=utf8                        //使用utf8字符

-DDEFAULT_COLLATION=utf8_general_ci            //校驗字符

-DEXTRA_CHARSETS=all                            //安裝所有擴展字符集

-DENABLED_LOCAL_INFILE=1                        //允許從本地導入數據 

注意事項:

重新編譯時,需要清除舊的對象文件和緩存信息。

# make clean# rm -f CMakeCache.txt# rm -rf /etc/my.cnf

2.配置

(1)設置目錄權限

[root@ rhel5~]# cd /usr/local/mysql[root@ rhel5 mysql]# chown -R root:mysql . //把當前目錄中所有文件的所有者所有者設為root,所屬組為mysql[root@ rhel5 mysql]# chown -R mysql:mysql data

(2)

[root@ rhel5 mysql]# cp support-files/my-medium.cnf /etc/my.cnf //將mysql的啟動服務添加到系統服務中

(3)創建系統數據庫的表

[root@ rhel5 mysql]# cd /usr/local/mysql[root@ rhel5 mysql]# scripts/mysql_install_db --user=mysql

(4)設置環境變量

[root@ rhel5~]# vi /root/.bash_profile

在PATH=$PATH:$HOME/bin添加參數為:

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

[root@ rhel5~]#source /root/.bash_profile

(5)手動啟動mysql

[root@ rhel5~]# cd /usr/local/mysql[root@ rhel5 mysql]# ./bin/mysqld_safe --user=mysql &   //啟動MySQL,但不能停止

啟動日志寫在此文件下:/usr/local/mysql/data/localhost.err

關閉MySQL服務

[root@ rhel5 mysql]# mysqladmin -u root -p shutdown //這里MySQL的root用戶還沒有配置密碼,所以為空值。需要輸入密碼時,直接點回車鍵即可。

(6)另一種簡單的啟動mysql的方法(mysql已經被添加到系統服務中)

[root@ rhel5~]# service mysql.server start [root@ rhel5~]# service mysql.server stop[root@ rhel5~]# service mysql.server restart

如果上述命令出現:mysql.server 未識別的服務

則可能mysql還沒添加到系統服務中,下面用另一種方法添加:

[root@ rhel5 mysql]# cp support-files/mysql.server  /etc/init.d/mysql //將mysql的啟動服務添加到系統服務中
注意:主要是將mysql.server拷貝到/etc/init.d中,命名為mysql。在有的系統中,mysql.server在/usr/local/mysql/share/mysql/mysql.server中,而本系統中,mysql.server在/usr/local/mysql/support-files/mysql.server中。

然后再用#service mysql start 來啟動mysql即可。

(7)修改MySQL的root用戶的密碼以及打開遠程連接

[root@ rhel5~]# mysql -u root mysqlmysql>use mysql;mysql>desc user;mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";  //為root添加遠程連接的能力。mysql>update user set Password = password('xxxxxx') where User='root';mysql>select Host,User,Password from user where User='root'; mysql>flush privileges;mysql>exit

重新登錄:mysql -u root -p

若還不能進行遠程連接,則關閉防火墻
[root@ rhel5~]# /etc/rc.d/init.d/iptables stop

注:如果不能遠程連接,出現錯誤mysql error number 1130,則加入下面語句試試:

 

復制代碼 代碼如下:
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '******' WITH GRANT OPTION;

 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網。


注:相關教程知識閱讀請移步到MYSQL教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 维西| 墨竹工卡县| 白河县| 白玉县| 吐鲁番市| 秦安县| 邵阳县| 高邑县| 砀山县| 青川县| 佳木斯市| 香港 | 佛山市| 垫江县| 敦煌市| 崇明县| 绩溪县| 郧西县| 涿鹿县| 桑植县| 嵊州市| 陆良县| 陆河县| 太保市| 大渡口区| 航空| 阳江市| 定结县| 甘孜县| 峨山| 高安市| 惠州市| 德安县| 萨嘎县| 天等县| 深圳市| 大名县| 平南县| 广安市| 贺兰县| 周宁县|