北京SEO

linux中安装mysql数据库的2种方法

2019/10/10/17:32:30  阅读:1844  来源:谷歌SEO算法  标签: 1号店SEO

安装mysql数据库在linux系统中有两种安装方法,一种是编译安装mysql 另一种是 免编译式安装mysql了,希望下文对各位有帮助.

编译安装mysql

安装前准备:如果mysql用户不存在,那么添加mysql用户.

groupadd mysql

useradd -g mysql mysql

mysql编译安装

  1. wgethttp://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.70.tar.gz
  2. tar-zxvfmysql-5.1.70.tar.gz
  3. cdmysql-5.1.70
  4. yuminstallncursesncurses-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. makeinstall

到此mysql就安装到了/usr/local/mysql路径下,下面开始mysql的配置工作.

安装mysql选项文件:

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

mysql设置开机自启动:

  1. cp-rsupport-files/mysql.server/etc/init.d/mysqld
  2. /sbin/chkconfig--delmysqld
  3. /sbin/chkconfig--addmysqld

配置权限表:

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:line260:my_print_defaults:commandnotfound
  2. /etc/init.d/mysqld:line263:my_print_defaults:commandnotfound
  3. /etc/init.d/mysqld:line270:@HOSTNAME@:commandnotfound
  4. /etc/init.d/mysqld:line279:@HOSTNAME@:commandnotfound
  5. /etc/init.d/mysqld:line292:cd:@prefix@:Nosuchfileordirectory
  6. StartingMySQLCouldn'tfindMySQLmanager(@bindir@/mysqlmanager)orserver(@bindir@/mysqld_safe)[FAILED]--phpfensi.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]:Enteringdirectory`/down/webinstall/mysql-5.1.57/mysql-test
  2. make[3]:Enteringdirectory`/down/webinstall/mysql-5.1.57/mysql-test
  3. make[3]:Nothingtobedonefor`install-exec-am.
  4. makeINSTALL_TO_DIR="/usr/local/mysql/mysql-test"install_test_files
  5. make[4]:Enteringdirectory`/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@hktools]#wgethttp://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.16-linux-glibc2.5-x86_64.tar.gz
  2. [root@hktools]#tarzxfmysql-5.6.16-linux-glibc2.5-x86_64.tar.gz
  3. [root@hktools]#mvmysql-5.6.16-linux-glibc2.5-x86_64/opt/
  4. [root@hkopt]#mvmysql-5.6.16-linux-glibc2.5-x86_64mysql
  5. [root@hkopt]#/usr/sbin/useraddmysql-s/sbin/nologin-M
  6. [root@hkopt]#cdmysql/
  7. [root@hkmysql]#/opt/mysql/scripts/mysql_install_db--basedir=/opt/mysql/--datadir=/opt/mysql/data--user=mysql
  8. [root@hkmysql]#mv/etc/my.cnf/etc/my.cnf.backup
  9. [root@hkmysql]#sed-i's#\#socket=.....#socket=/tmp/mysql.sock#g'my.cnf
  10. [root@hkmysql]#cp/opt/mysql/my.cnf/etc/my.cnf
  11. [root@hkmysql]#/opt/mysql/support-files/mysql.serverstart
  12. [root@hkmysql]#netstat-tunlp
  13. ActiveInternetconnections(onlyservers)
  14. ProtoRecv-QSend-QLocalAddressForeignAddressStatePID/Programname
  15. tcp00:::3306:::*LISTEN28104/mysqld
  16. [root@hkmysql]#/opt/mysql/bin/mysql-uroot-p
  17. Enterpassword:
  18. ERROR2002(HY000):Can'tconnecttolocalMySQLserverthroughsocket'/tmp/mysql.sock'(2)#看下面的sock的配置
  19. [root@hkmysql]#sed-i's#\#socket=.....#socket=/tmp/mysql.sock#g'my.cnf
  20. [root@hkmysql]#/opt/mysql/bin/mysql-uroot-p
  21. Enterpassword:
  22. ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:YES)#居然报错
  23. [root@hkmysql]#/opt/mysql/bin/mysqld_safe--skip-grant-tables&
  24. [1]30062
  25. mysql>updatemysql.usersetpassword=PASSWORD('admin123')whereuser='root';#设置密码
  26. mysql>flushprivileges;
  27. [root@hkmysql]#skill30194
  28. [root@hkmysql]#14060100:14:38mysqld_safemysqldfrompidfile/opt/mysql/data/hk.t4x.org.pidended
  29. [1]+Done/opt/mysql/bin/mysqld_safe--skip-grant-tables
  30. [root@hkmysql]#/opt/mysql/bin/mysql-uroot-p
  31. Enterpassword:
  32. ERROR1045(28000):Accessdeniedforuser'root'@'localhost'(usingpassword:YES)#错误依旧
  33. [root@hkmysql]#vim/usr/local/mysql/support-files/mysql.server#配置文件中默认配置目录是/usr/local/mysql
  34. [root@hkmysql]#ln-s/opt/mysql/usr/local/mysql#设置软连接
  35. [root@hkmysql]#/usr/local/mysql/bin/mysql-uroot-p'admin123'
  36. mysql>

广告内容

linux中安装mysql数据库的2种方法 linux中安装mysql数据库的2种方法 linux中安装mysql数据库的2种方法

相关阅读

热门评论

萧红SEO 萧红SEO

SEO爱好者,分享SEO经验~

总篇数212

精选文章

RMAN中catalog和nocatalog区别介绍 小技巧:为Linux下的文件分配多个权限 zimbra8.5.1安装第三方签名ssl证书的步骤 解决mysql不能远程连接数据库方法 windows服务器mysql增量备份批处理数据库 mysql中slow query log慢日志查询分析 JavaScript跨域问题总结 Linux下负载均衡软件LVS配置(VS/DR)教程 mysql中权限参数说明 MYSQL(错误1053)无法正常启动

SEO最新算法