3 ways to start mysql

1、mysqld start mysql:./mysqld –defaults-file=/etc/my.cnf –user=root client connect: mysql –defaults-file=/etc/my.cnf or mysql -S /tmp/mysql.sock 2、mysqld_safe start mysql: ./mysqld_safe –defaults-file=/etc/my.cnf –user=root & client connect: mysql –defaults-file=/etc/my.cnf or…

MySQL 5.7数据库安装以及配置参数

一、从官网下载Percona5.7 需要注意是服务器的版本。我这里选择的是Percona-Server-5.7.20-19-r119-el6-x86_64-bundle.tar 二、解压 tar xvf Percona-Server-5.7.20-19-r119-el6-x86_64-bundle.tar 能够看到解压出7个文件 [root@localhost percona]# tar xvf Percona-Server-5.7.20-19-r119-el6-x86_64-bundle.tar Percona-Server-57-debuginfo-5.7.20-19.1.el6.x86_64.rpm Percona-Server-client-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-devel-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-rocksdb-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-server-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-shared-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-test-57-5.7.20-19.1.el6.x86_64.rpm Percona-Server-tokudb-57-5.7.20-19.1.el6.x86_64.rpm mv Percona-Server-5.7.20-19-r119-el6-x86_64-bundle.tar /opt 三 .…

解决MySQL sleep连接太多

  执行show processlist;后打印出大量状态为sleep的连接,可能会有两三百个, 这些都是客户端和 数据库通信后没有释放的。大量的连接会严重拖慢系统速度,阻塞新的MySQL连接建立, 甚至造成MySQL报错, 无法响应。 问题产生的根源有以下3种情况 1.使用了太多持久连接 2.程序中,没有及时关闭mysql连接 3.数据库查询不够优化,过度耗时   最根本的办法是从以上3种情况排查 1.程序中,不使用持久链接,即使用mysql_connect而不是pconnect 2.程序执行完毕,应该显式调用mysql_close 3.只能逐步分析系统的SQL查询,开启慢查询日志,找出低效的SQL语句,然后优化 这是从研发角度排查,如果不方便在代码方面变更, 又想解决问题, 那么就要依靠mysql本身的超时功能解决,命令行键入 mysql> show global variables like “%timeout%”;…

MySQL brief note

only export table data , exclude table structure: mysqldump -uuser -ppassword -t db_name > /dump_name.sql only export table structure ,exclude table data: mysqldump -uuser -ppassword…