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

首頁 > 數據庫 > MySQL > 正文

linux中安裝mysql數據庫的2種方法

2024-07-24 12:39:38
字體:
來源:轉載
供稿:網友

安裝mysql數據庫在linux系統中有兩種安裝方法,一種是編譯安裝mysql 另一種是 免編譯式安裝mysql了,希望下文對各位有幫助.

編譯安裝mysql

安裝前準備:如果mysql用戶不存在,那么添加mysql用戶.

groupadd mysql

useradd -g mysql mysql

mysql編譯安裝

  1. wget http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.70.tar.gz 
  2. tar -zxvf mysql-5.1.70.tar.gz 
  3. cd mysql-5.1.70 
  4. yum install ncurses ncurses-devel 
  5. ./configure  '--prefix=/usr/local/mysql' '--without-debug' '--with-charset=utf8' '--with-extra-charsets=all' '--enable-assembler' '--with-pthread' '--enable-thread-safe-client' '--with-mysqld-ldflags=-all-static' '--with-client-ldflags=-all-static' '--with-big-tables' '--with-readline' '--with-ssl' '--with-embedded-server' '--enable-local-infile' '--with-plugins=innobase' 
  6. make 
  7. make install 

到此mysql就安裝到了/usr/local/mysql路徑下,下面開始mysql的配置工作.

安裝mysql選項文件:

cp support-files/my-medium.cnf /etc/my.cnf

mysql設置開機自啟動:

  1. cp -r support-files/mysql.server /etc/init.d/mysqld   
  2. /sbin/chkconfig --del mysqld 
  3. /sbin/chkconfig --add mysqld 

配置權限表:

chown -R mysql:mysql /usr/local/mysql

/usr/local/mysql/bin/mysql_install_db --user=mysql

啟動mysql:/etc/init.d/mysqld start

這一步可能會報錯:

  1. /etc/init.d/mysqld: line 260: my_print_defaults: command not found 
  2. /etc/init.d/mysqld: line 263: my_print_defaults: command not found 
  3. /etc/init.d/mysqld: line 270: @HOSTNAME@: command not found 
  4. /etc/init.d/mysqld: line 279: @HOSTNAME@: command not found 
  5. /etc/init.d/mysqld: line 292: cd: @prefix@: No such file or directory 
  6. Starting MySQLCouldn't find MySQL manager (@bindir@/mysqlmanager) or server (@bindir@/mysqld_safe) [FAILED]  --Vevb.com 

因為路徑沒有設置,請重啟確認上面配置工作是否都完成,一般是configure后沒有make和make install.

mysql初始化配置:

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

/usr/local/mysql/bin/mysql_secure_installation

mysql如何導入舊的數據:

直接拷貝數據庫文件夾到數據目錄下然后執行

/usr/local/mysql/bin/mysqladmin -u root -p flush-tables

mysql安裝過程中問題:

  1. make[2]: Entering directory `/down/webinstall/mysql-5.1.57/mysql-test 
  2. make[3]: Entering directory `/down/webinstall/mysql-5.1.57/mysql-test 
  3. make[3]: Nothing to be done for `install-exec-am. 
  4. make INSTALL_TO_DIR="/usr/local/mysql/mysql-test" install_test_files 
  5. make[4]: Entering directory `/down/webinstall/mysql-5.1.57/mysql-test 

時間較長:MYSQL安裝到這里卡了很久,可能以為出錯了,實際上MYSQL已經安裝成功了,它這步過段時間就會好了,是mysql在自我編譯測試造成的.

2.checking for termcap functions library... configure: error: No curses/termcap library found

yum install ncurses ncurses-devel

3.Starting MySQL.Manager of pid-file quit without updating fi[FAILED]

啟動數據庫之前,需要先配置權限表,其中/usr/local/mysql為mysql的安裝目錄.

chown -R mysql:mysql /usr/local/mysql

/usr/local/mysql/bin/mysql_install_db --user=mysql

上面安裝mysql是通過編譯的方式安裝,此次不進行編譯,直接安裝.

  1. [root@hk tools]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz 
  2. [root@hk tools]# tar zxf mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz 
  3. [root@hk tools]# mv mysql-5.6.16-linux-glibc2.5-x86_64 /opt/ 
  4. [root@hk opt]# mv mysql-5.6.16-linux-glibc2.5-x86_64 mysql 
  5. [root@hk opt]# /usr/sbin/useradd mysql -s /sbin/nologin -M 
  6. [root@hk opt]# cd mysql/ 
  7. [root@hk mysql]# /opt/mysql/scripts/mysql_install_db --basedir=/opt/mysql/ --datadir=/opt/mysql/data --user=mysql  
  8. [root@hk mysql]# mv /etc/my.cnf /etc/my.cnf.backup 
  9. [root@hk mysql]# sed -i 's#\# socket = .....# socket = /tmp/mysql.sock#g' my.cnf  
  10. [root@hk mysql]# cp /opt/mysql/my.cnf /etc/my.cnf 
  11. [root@hk mysql]# /opt/mysql/support-files/mysql.server start 
  12. [root@hk mysql]# netstat -tunlp 
  13. Active Internet connections (only servers) 
  14. Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name    
  15. tcp        0      0 :::3306                     :::*                        LISTEN      28104/mysqld   
  16. [root@hk mysql]#  /opt/mysql/bin/mysql -uroot -p 
  17. Enter password:  
  18. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) #看下面的sock的配置 
  19. [root@hk mysql]# sed -i 's#\# socket = .....# socket = /tmp/mysql.sock#g' my.cnf  
  20. [root@hk mysql]# /opt/mysql/bin/mysql -uroot -p 
  21. Enter password:  
  22. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)   #居然報錯 
  23. [root@hk mysql]# /opt/mysql/bin/mysqld_safe --skip-grant-tables &  
  24. [1] 30062 
  25. mysql> update mysql.user set password=PASSWORD('admin123'where user='root';    #設置密碼 
  26. mysql> flush privileges
  27. [root@hk mysql]# skill 30194 
  28. [root@hk mysql]# 140601 00:14:38 mysqld_safe mysqld from pid file /opt/mysql/data/hk.t4x.org.pid ended 
  29. [1]+  Done                    /opt/mysql/bin/mysqld_safe --skip-grant-tables 
  30. [root@hk mysql]# /opt/mysql/bin/mysql -uroot -p 
  31. Enter password:  
  32. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)    #錯誤依舊 
  33. [root@hk mysql]# vim /usr/local/mysql/support-files/mysql.server   #配置文件中默認配置目錄是/usr/local/mysql 
  34. [root@hk mysql]# ln -s /opt/mysql /usr/local/mysql    #設置軟連接 
  35. [root@hk mysql]# /usr/local/mysql/bin/mysql -uroot -p'admin123' 
  36. mysql>

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 青河县| 临澧县| 丰都县| 南华县| 千阳县| 兴化市| 阳新县| 扶风县| 社旗县| 宜州市| 宜都市| 菏泽市| 准格尔旗| 广西| 施秉县| 宁阳县| 蓬溪县| 呼玛县| 凤翔县| 平定县| 长宁县| 敦煌市| 三亚市| 冷水江市| 海伦市| 长海县| 霍山县| 东平县| 秦皇岛市| 张北县| 抚宁县| 什邡市| 封丘县| 浪卡子县| 台前县| 泰安市| 嘉定区| 司法| 平阳县| 长泰县| 清苑县|