最近公司某个项目要用mysql5.6版本,又要整理份安装文档。真心不爱写安装文档类,贴于此。
1. 安装必要的组件文章源自运维生存时间-https://www.ttlsa.com/mysql/install-mysql5_6/
# yum install –y autoconf automake imake libxml2-devel\ expat-devel cmake gcc gcc-c++ libaio libaio-devel bzr bison libtool ncurses5-devel
2. 下载解压mysql软件文章源自运维生存时间-https://www.ttlsa.com/mysql/install-mysql5_6/
# cd /usr/local/src # wget -c http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz/from/http://cdn.mysql.com/ -O mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz # tar zxvf mysql-5.6.14-linux-glibc2.5-x86_64.tar.gz –C ../ # cd /usr/local/ # ln -s mysql-5.6.14-linux-glibc2.5-x86_64 mysql
3. 创建Mysql用户组和用户,及数据库存放目录:文章源自运维生存时间-https://www.ttlsa.com/mysql/install-mysql5_6/
# mkdir -p /data/mysql_data_3306 # mkdir -p /data/mysql_log # mkdir -p /data/log-bin # groupadd mysql # useradd mysql -g mysql -M -s /sbin/nologin # chown -R mysql.mysql /data/mysql_data_3306 /data/mysql_log /data/log-bin # chown -R mysql.mysql /usr/local/mysql-5.6.14-linux-glibc2.5-x86_64
4. 配置文件(依具体环境)
# vi /etc/my.cnf文章源自运维生存时间-https://www.ttlsa.com/mysql/install-mysql5_6/
[mysqld] # GENERAL # user = mysql default-storage-engine = InnoDB socket = /data/mysql_data_3306/mysql.sock pid-file = /data/mysql_data_3306/mysql.pid port = 3306 # MyISAM # key_buffer_size = 1344M myisam_recover = FORCE,BACKUP # SAFETY # max_allowed_packet = 16M max_connect_errors = 1000000 skip_name_resolve # DATA STORAGE # datadir = /data/mysql_data_3306/ long_query_time = 1 # BINARY LOGGING # log-bin = /data/log-bin/mysql-bin-3306 expire-logs-days = 14 sync-binlog = 1 server-id = 1 max_binlog_size = 500M # REPLICATION # relay-log = /data/log-bin/relay-bin-3306 slave-net-timeout = 60 # CACHES AND LIMITS # tmp_table_size = 32M max_heap_table_size = 32M max_connections = 500 thread_cache_size = 50 open_files_limit = 65535 table_definition_cache = 4096 table_open_cache = 4096 # INNODB # innodb_data_file_path = ibdata1:128M;ibdata2:10M:autoextend innodb_flush_method = O_DIRECT innodb_log_files_in_group = 2 innodb_lock_wait_timeout = 50 innodb_log_file_size = 256M innodb_flush_log_at_trx_commit = 1 innodb_file_per_table = 1 innodb_thread_concurrency = 8 innodb_buffer_pool_size = 8G # LOGGING # log-error = /data/mysql_log/mysql-error-3306.log log-queries-not-using-indexes = 1 slow-query-log = 1 long_query_time = 1 slow-query-log-file = /data/mysql_log/mysql-slow-3306.log # FOR SLAVE # #binlog-format = ROW #log-slave-updates = true #gtid-mode = on #enforce-gtid-consistency = true #master-info-repository = TABLE #relay-log-info-repository = TABLE #sync-master-info = 1 #slave-parallel-workers = 2 #binlog-checksum = CRC32 #master-verify-checksum = 1 #slave-sql-verify-checksum = 1 #binlog-rows-query-log_events = 1 #report-port = 3306 #report-host = 10.1.1.10
5. 系统服务文章源自运维生存时间-https://www.ttlsa.com/mysql/install-mysql5_6/
# cp -af /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld_3306 # vi /etc/init.d/mysqld_3306 修改两处位置: basedir=/usr/local/mysql datadir=/data/mysql_data_3306 执行如下命令 # chmod 755 /etc/init.d/mysqld_3306 # chkconfig --add mysqld_3306 # chkconfig --level 345 mysqld_3306 on
文章源自运维生存时间-https://www.ttlsa.com/mysql/install-mysql5_6/
6. 初始化数据库
# cd /usr/local/mysql # ./scripts/mysql_install_db --user=mysql --defaults-file=/etc/my.cnf
7. 启动数据库进程
# service mysqld_3306 start
8. 修改root密码
# /usr/local/mysql/bin/mysql -p -uroot -S /tmp/mysql.sock #这里直接回车就能进入数据库系统 Mysql> delete from mysql.user where user=''; Mysql> update mysql.user set password=PASSWORD(‘xxxxxxxx’) where user='root'; Mysql>flush privileges;
文章源自运维生存时间-https://www.ttlsa.com/mysql/install-mysql5_6/ 文章源自运维生存时间-https://www.ttlsa.com/mysql/install-mysql5_6/
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
23F
不要编译安装吗,这样装有很多问题的
22F
这个教程的版本是5.6的 . 我装了4次才成功 .
如果你从官网下最新版本5.7的不可以的. 我试过了就会出现.
The server quit without updating PID file
然后又下了5.6. 由于没有删除干净 还是出现上面问题
最后执行 find / -name mysql
把 mysql 相关的目录都删除 重新解压才成功.
补充:
./scripts/mysql_install_db –user=mysql –defaults-file=/etc/my.cnf
在执行这个的时候 会出现
starting as process 7631 …OK
还有一些 提示修改密码的语句 才是成功的.
前面装了 3次 都没出现. 教程上面也没说 以为没事.
还有 最后那句的路径是错的. 一开始没看评论.
查了半天…突然看到路径不统一才知道.
/usr/local/mysql/bin/mysql -p -uroot -S /tmp/mysql.sock
改成
/usr/local/mysql/bin/mysql -p -uroot -S /data/mysql_data_3306/mysql.sock
谢谢楼主的分享, 欢迎大家交流:qq237687286
21F
看看再说!!!!
20F
路过看看!!!!
19F
在my.cnf
[mysqld]
要在下面加个
explicit_defaults_for_timestamp=true
18F
centos安装mariadb,可以百度一下,这个是mysql作者基于mysql开发的,和mysql完全一样
yum install mariadb-server -y
然后启动服务
systemctl start mariadb.service
这样省事多了。
17F
按照教程一步一步配置,启动时出现如下错误,该如何解决,mysql.pid是如何来的?
[root@myaliyun mysql]# service mysqld_3306 start
Starting MySQL..The server quit without updating PID file ([FAILED]sql_data_3306/mysql.pid).
B1
@ adong2838 这个教程的版本是5.6的 . 我装了4次才成功 .
如果你从官网下最新版本5.7的不可以的. 我试过了就会出现.
The server quit without updating PID file
然后又下了5.6. 由于没有删除干净 还是出现上面问题
最后执行 find / -name mysql
把 mysql 相关的目录都删除
重新解压安装才成功.
16F
我真的真的真的无语了
做了一天
就你这个mysql 出问题
一直出
我真的无语了
B1
@ 匿名 就最后一句修改下就可以了,做出来了。教程没有问题
最后一局修改如下:/usr/local/mysql/bin/mysql -p -uroot -S /data/mysql_data_3306/mysql.sock
15F
额..
你这写的 我都乱了
没有编译安装的话 可以初始化mysql吗
我的 scripts 里面没有那个文件
14F
# /usr/local/mysql/bin/mysql -p -uroot -S /tmp/mysql.sock #这里直接回车就能进入数据库系统
是 mysql.sock 定义的路径 — —>> /*/mysql.sock
13F
Starting MySQL.. ERROR! The server quit without updating PID file (/data/mysql_data_3306/mysql.pid).
启动mysql出来这个错误。
12F
最后一句应该是/usr/local/mysql/bin/mysql -p -uroot -S /data/mysql_data_3306/mysql.sock,第一次不用密码,改完后必须使用密码登入
B1
@ CTNET 麻烦问下我做到/usr/local/mysql/bin/mysql -p -uroot -S /data/mysql_data_3306/mysql.sock这个步骤,提示我输入密码,但无论我输与不输入都提示我这个错误:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: YES)
请问该如何解决呀???急死了快,
B2
@ 提问的孩子 解决了。需要用/usr/local/mysql/mysql -u mysql登陆后再修改用户和密码。
B3
@ 提问的孩子 /usr/local/mysql/mysql -u mysql 都找不到这个文件?您遇到的问题怎么解决的
B4
@ 匿名 路径不对. 看下你的mysql执行文件在哪个目录下.
这个教程上面 建立了一个类似快捷方式的链接的命令
ln -s
如果这个命令的链接你建立错误 也会报错的.
11F
从初始化那一步重做,—-defaults-file去掉前面两个横杠。
10F
参数的问题
9F
楼主 ,这个mysql 的安装过程是有问题的, 可能是配置参数, 我在初始化的时候报
2015-08-27 12:18:24 9957 [Note] InnoDB: The InnoDB memory heap is disabled
2015-08-27 12:18:24 9957 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-08-27 12:18:24 9957 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-08-27 12:18:24 9957 [Note] InnoDB: Using Linux native AIO
2015-08-27 12:18:24 9957 [Note] InnoDB: Using CPU crc32 instructions
2015-08-27 12:18:24 9957 [Note] InnoDB: Initializing buffer pool, size = 8.0G
InnoDB: mmap(1098907648 bytes) failed; errno 12
2015-08-27 12:18:24 9957 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2015-08-27 12:18:24 9957 [ERROR] Plugin ‘InnoDB’ init function returned error.
2015-08-27 12:18:24 9957 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed.
2015-08-27 12:18:24 9957 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-08-27 12:18:24 9957 [ERROR] Aborting
2015-08-27 12:18:24 9957 [Note] Binlog end
2015-08-27 12:18:24 9957 [Note] ./bin/mysqld: Shutdown complete
我是用的虚拟机 512M内在 ,在网上搜索了,但是没有解决问题。
key_buffer_size = 设置 128M 256M 400M 都是不行的。 是不是5.6要求操作系统的配置?
B1
@ orcs 错误日志很清楚啊、 2015-08-27 12:18:24 9957 [Note] InnoDB: Initializing buffer pool, size = 8.0G
InnoDB: mmap(1098907648 bytes) failed; errno 12
2015-08-27 12:18:24 9957 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
把这个改小innodb_buffer_pool_size
B2
@ 默北 楼上正解
8F
教程是错的,根本跑步起来,MYSQL启动不了,提示the server quit without updating pid file 失败(ib/mysql/localhost.localdomain.pid),博主太不负责任了。
B1
@ 风衣 你要看看错误日志,可能你指定到错误的my.cnf文件上了。
7F
7. 启动数据库进程
# service mysqld_3306 start
ERROR! The server quit without updating PID file
6F
# chown -R mysql.mysql /usr/local/mysql-5.6.14
楼主,这里/usr/local/目录下哪里来的mysql-5.6.14这个目录呢,我是按照你的步骤走的
B1
@ 上班 漏了一步mv
B2
@ ttlsa 哪个目录需要移动?mv怎么写呢?
5F
请问下,这个my.cnf是依具体环境而定的,那么我如何知道这个配置是不是适合我的机器啊?谢谢
4F
各们在执行chkconfig –level 345 mysqld_3306 on这句时会不会遇到error reading information on service /etc/init.d/mysql_3306: No such file or directory的报错啊?
B1
@ Baylor.Qu mysqld_3306有个d
3F
[root@ysp mysql]# ./bin/mysqld_safe –user=mysql &
” /> 17450
[root@ysp mysql]# 140723 19:22:29 mysqld_safe Logging to ‘/var/log/mysqld.log’.
140723 19:22:29 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
140723 19:22:31 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
” /> + Done ./bin/mysqld_safe –user=mysql
安装官方正常的步骤竟然还有这样的问题,两台Centos6.5测试一样的问题。不知楼主可有遇到?
B1
@ " 梦 想 粺 什么问题?
2F
安装楼主的文章 Mysql搞不定。 = = 最后还是直接YUM了。
B1
@ " 梦 想 粺 ncurses5-devel Centos里面安装不能带5 否则会找不到。应该:yum install ncurses-devel—看这个评论
B1
@ " 梦 想 粺 这个也是我发的,我安装了ncurses了。 楼主 我加您群了,麻烦您审核一下。 希望能跟您多多交流。
1F
ncurses5-devel Centos里面安装不能带5 否则会找不到。应该:yum install ncurses-devel
来自外部的引用