ITPub博客

首页 > 数据库 > MySQL > 源码安装mysql错误

源码安装mysql错误

原创 MySQL 作者:warren20 时间:2015-09-09 15:21:35 0 删除 编辑
今天有个新手遇到一个问题,说是数据库都安装完了,但是就是服务起不来,这里特地将问题处理步骤记录下来:

1 查看mysql的配置文件
  1. [root@idc mysql]# more /etc/my.cnf
  2. [client]
  3. socket=/var/lib/mysql/mysql.sock


  4. [mysqld]
  5. datadir=/var/lib/mysql
  6. socket=/var/lib/mysql/mysql.sock
  7. # user=mysql
  8. # Disabling symbolic-links is recommended to prevent assorted security risks
  9. symbolic-links=0

  10. [mysqld_safe]
  11. log-error=/var/log/mysqld.log
  12. pid-file=/var/run/mysqld/mysqld.pid
  13. skip-grant-tables
2 启动mysql服务
  1. [root@idc support-files]# ./mysql.server start
  2. Starting MySQL. The server quit without updating PID file (/var/lib/mysql/idc.pid).

  3. 150909 19:39:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  4. 2015-09-09 19:39:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  5. 2015-09-09 19:39:06 6659 [Note] Plugin 'FEDERATED' is disabled.
  6. /usr/local/mysql56/bin/mysqld: Table 'mysql.plugin' doesn't exist
  7. 2015-09-09 19:39:06 6659 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
  8. 2015-09-09 19:39:06 6659 [Note] InnoDB: The InnoDB memory heap is disabled
  9. 2015-09-09 19:39:06 6659 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  10. 2015-09-09 19:39:06 6659 [Note] InnoDB: Compressed tables use zlib 1.2.3
  11. 2015-09-09 19:39:06 6659 [Note] InnoDB: Using CPU crc32 instructions
  12. 2015-09-09 19:39:06 6659 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  13. 2015-09-09 19:39:06 6659 [Note] InnoDB: Completed initialization of buffer pool
  14. 2015-09-09 19:39:06 6659 [Note] InnoDB: Highest supported file format is Barracuda.
  15. 2015-09-09 19:39:06 6659 [Note] InnoDB: 128 rollback segment(s) are active.
  16. 2015-09-09 19:39:06 6659 [Note] InnoDB: Waiting for purge to start
  17. 2015-09-09 19:39:06 6659 [Note] InnoDB: 5.6.13 started; log sequence number 1600687
  18. 2015-09-09 19:39:06 6659 [Note] Server hostname (bind-address): '*'; port: 3306
  19. 2015-09-09 19:39:06 6659 [Note] IPv6 is available.
  20. 2015-09-09 19:39:06 6659 [Note] - '::' resolves to '::';
  21. 2015-09-09 19:39:06 6659 [Note] Server socket created on IP: '::'.
  22. 2015-09-09 19:39:06 6659 [Note] Server socket created on IP: '::'.
  23. 2015-09-09 19:39:06 6659 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
  24. 150909 19:39:06 mysqld_safe mysqld from pid file /var/lib/mysql/idc.pid ended
  25. 150909 19:58:38 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
  26. 2015-09-09 19:58:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  27. 2015-09-09 19:58:38 7955 [Note] Plugin 'FEDERATED' is disabled.
  28. 2015-09-09 19:58:38 7955 [Note] InnoDB: The InnoDB memory heap is disabled
  29. 2015-09-09 19:58:38 7955 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  30. 2015-09-09 19:58:38 7955 [Note] InnoDB: Compressed tables use zlib 1.2.3
  31. 2015-09-09 19:58:38 7955 [Note] InnoDB: Using CPU crc32 instructions
  32. 2015-09-09 19:58:38 7955 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  33. 2015-09-09 19:58:38 7955 [Note] InnoDB: Completed initialization of buffer pool
  34. 2015-09-09 19:58:38 7955 [Note] InnoDB: Highest supported file format is Barracuda.
  35. 2015-09-09 19:58:39 7955 [Note] InnoDB: 128 rollback segment(s) are active.
  36. 2015-09-09 19:58:39 7955 [Note] InnoDB: Waiting for purge to start
  37. 2015-09-09 19:58:39 7955 [Note] InnoDB: 5.6.13 started; log sequence number 1626077
  38. 2015-09-09 19:58:39 7955 [Note] Server hostname (bind-address): '*'; port: 3306
  39. 2015-09-09 19:58:39 7955 [Note] IPv6 is available.
  40. 2015-09-09 19:58:39 7955 [Note] IPv6 is available.
  41. 2015-09-09 19:58:39 7955 [Note] - '::' resolves to '::';
  42. 2015-09-09 19:58:39 7955 [Note] Server socket created on IP: '::'.
  43. 2015-09-09 19:58:39 7955 [Note] Event Scheduler: Loaded 0 events
  44. 2015-09-09 19:58:39 7955 [Note] /usr/local/mysql56/bin/mysqld: ready for connections.
  45. Version: '5.6.13' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
  46. 150909 19:59:54 mysqld_safe A mysqld process already exists
  47. 2015-09-09 20:00:10 7955 [Note] /usr/local/mysql56/bin/mysqld: Normal shutdown
搜索错误 :Can't open the mysql.plugin table. Please run mysql_upgrade to create it 网上说是要初始化数据库,于是进入mysql数据文件所在的目录

3 查看数据文件所在的目录
  1. [root@idc ~]# cd /var/lib/mysql
  2. [root@idc mysql]# ll
  3. 总用量 110596
  4. -rw-rw---- 1 mysql mysql 56 9月 9 03:06 auto.cnf
  5. -rw-rw---- 1 mysql mysql 12582912 9月 9 19:32 ibdata1
  6. -rw-rw---- 1 mysql mysql 50331648 9月 9 19:37 ib_logfile0
  7. -rw-rw---- 1 mysql mysql 50331648 9月 9 03:06 ib_logfile1
发现相关的系统数据库都没有,于是就初始化数据库

4 初始化数据库
  1. [root@idc scripts]# ./mysql_install_db --user=mysql --datadir=/var/lib/mysql
  2. FATAL ERROR: Could not find ./bin/my_print_defaults

  3. If you compiled from source, you need to run 'make install' to
  4. copy the software into the correct location ready for operation.

  5. If you are using a binary release, you must either be at the top
  6. level of the extracted archive, or pass the --basedir option
  7. pointing to that location.
于是搜索: FATAL ERROR: Could not find ./bin/my_print_defaults   网上说是没有指定basedir

5 指定basedir 重新初始化数据库
  1. [root@idc scripts]# ./mysql_install_db --user=mysql --datadir=/var/lib/mysql --basedir=/usr/local/mysql56/ &
  2. [1] 7569
  3. [root@idc scripts]# WARNING: The host 'idc' could not be looked up with /usr/local/mysql56//bin/resolveip.
  4. This probably means that your libc libraries are not 100 % compatible
  5. with this binary MySQL version. The MySQL daemon, mysqld, should work
  6. normally with the exception that host name resolving will not work.
  7. This means that you should use IP addresses instead of hostnames
  8. when specifying MySQL privileges !

  9. Installing MySQL system tables...2015-09-09 19:55:49 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  10. 2015-09-09 19:55:49 7576 [Note] InnoDB: The InnoDB memory heap is disabled
  11. 2015-09-09 19:55:49 7576 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  12. 2015-09-09 19:55:49 7576 [Note] InnoDB: Compressed tables use zlib 1.2.3
  13. 2015-09-09 19:55:49 7576 [Note] InnoDB: Using CPU crc32 instructions
  14. 2015-09-09 19:55:49 7576 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  15. 2015-09-09 19:55:49 7576 [Note] InnoDB: Completed initialization of buffer pool
  16. 2015-09-09 19:55:49 7576 [Note] InnoDB: Highest supported file format is Barracuda.
  17. 2015-09-09 19:55:49 7576 [Note] InnoDB: 128 rollback segment(s) are active.
  18. 2015-09-09 19:55:49 7576 [Note] InnoDB: Waiting for purge to start
  19. 2015-09-09 19:55:49 7576 [Note] InnoDB: 5.6.13 started; log sequence number 1600687
  20. 2015-09-09 19:55:55 7576 [Note] Binlog end
  21. 2015-09-09 19:55:55 7576 [Note] InnoDB: FTS optimize thread exiting.
  22. 2015-09-09 19:55:55 7576 [Note] InnoDB: Starting shutdown...
  23. 2015-09-09 19:55:56 7576 [Note] InnoDB: Shutdown completed; log sequence number 1626067
  24. OK

  25. Filling help tables...2015-09-09 19:55:56 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
  26. 2015-09-09 19:55:56 7606 [Note] InnoDB: The InnoDB memory heap is disabled
  27. 2015-09-09 19:55:56 7606 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
  28. 2015-09-09 19:55:56 7606 [Note] InnoDB: Compressed tables use zlib 1.2.3
  29. 2015-09-09 19:55:56 7606 [Note] InnoDB: Using CPU crc32 instructions
  30. 2015-09-09 19:55:56 7606 [Note] InnoDB: Initializing buffer pool, size = 128.0M
  31. 2015-09-09 19:55:56 7606 [Note] InnoDB: Completed initialization of buffer pool
  32. 2015-09-09 19:55:56 7606 [Note] InnoDB: Highest supported file format is Barracuda.
  33. 2015-09-09 19:55:56 7606 [Note] InnoDB: 128 rollback segment(s) are active.
  34. 2015-09-09 19:55:56 7606 [Note] InnoDB: Waiting for purge to start
  35. 2015-09-09 19:55:56 7606 [Note] InnoDB: 5.6.13 started; log sequence number 1626067
  36. 2015-09-09 19:55:56 7606 [Note] Binlog end
  37. 2015-09-09 19:55:56 7606 [Note] InnoDB: FTS optimize thread exiting.
  38. 2015-09-09 19:55:56 7606 [Note] InnoDB: Starting shutdown...
  39. 2015-09-09 19:55:57 7606 [Note] InnoDB: Shutdown completed; log sequence number 1626077
  40. OK

  41. To start mysqld at boot time you have to copy
  42. support-files/mysql.server to the right place for your system

  43. PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
  44. To do so, start the server, then issue the following commands:

  45.   /usr/local/mysql56//bin/mysqladmin -u root password 'new-password'
  46.   /usr/local/mysql56//bin/mysqladmin -u root -h idc password 'new-password'

  47. Alternatively you can run:

  48.   /usr/local/mysql56//bin/mysql_secure_installation

  49. which will also give you the option of removing the test
  50. databases and anonymous user created by default. This is
  51. strongly recommended for production servers.

  52. See the manual for more instructions.

  53. You can start the MySQL daemon with:

  54.   cd . ; /usr/local/mysql56//bin/mysqld_safe &

  55. You can test the MySQL daemon with mysql-test-run.pl

  56.   cd mysql-test ; perl mysql-test-run.pl

  57. Please report any problems with the ./bin/mysqlbug

  58. The latest information about MySQL is available on the web at

  59.   http://www.mysql.com

  60. Support MySQL by buying support/licenses at http://shop.mysql.com

  61. WARNING: Found existing config file /usr/local/mysql56//my.cnf on the system.
  62. Because this file might be in use, it was not replaced,
  63. but was used in bootstrap (unless you used --defaults-file)
  64. and when you later start the server.
  65. The new default config file was created as /usr/local/mysql56//my-new.cnf,
  66. please compare it with your file and take the changes you need.

  67. WARNING: Default config file /etc/my.cnf exists on the system
  68. This file will be read by default by the MySQL server
  69. If you do not want to use this, either remove it, or use the
  70. --defaults-file argument to mysqld_safe when starting the server
6 启动数据
  1. [root@idc mysql]# /usr/local/mysql56/support-files/mysql.server start
  2. Starting MySQL. SUCCESS! 
  3. [root@idc mysql]# cp /usr/local/mysql56/support-files/mysql.server /etc/init.d/mysqld
 
 -- 重置密码
 [root@idc mysql]# /usr/local/mysql56//bin/mysqladmin -u root password '123456'

至此,问题解决!

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30150152/viewspace-1795425/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: mysql日志删除
请登录后发表评论 登录
全部评论

注册时间:2015-03-03

  • 博文量
    56
  • 访问量
    376702