performance_schema库被删除怎么办

MySQLwubx 回复了问题 • 2 人关注 • 3 个回复 • 538 次浏览 • 2015-12-24 19:44 • 来自相关话题

一个是执行语句突然报个lost,还有一个是#sql-ib928已存在

MySQLwubx 回复了问题 • 2 人关注 • 1 个回复 • 420 次浏览 • 2015-12-24 00:11 • 来自相关话题

3分钟搞定MySQL5.7安装

MySQLzhangdh 发表了文章 • 3 个评论 • 862 次浏览 • 2015-12-22 19:49 • 来自相关话题

1.下载MySQL5.7二进制版本mkdir /opt/mysql
cd /opt/mysql
wget [url]http://downloads.mysql.com/arc ... ar.gz[/url]2.解压MySQL5.7到/opt/mysql下tar zxf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz3. 创建一个软连接,方便升级cd /usr/local ln -s /opt/mysql/mysql-5.7.9-linux-glibc2.5-x86_64 mysql4. 创建MySQl启动用户和组groupadd mysql
useradd -d /usr/local/mysql -g mysql -s /sbin/nologin mysql chown -R mysql:mysql /usr/local/mysql5. 创建基本目录mkdir -p /data/mysql/mysql3307/{data,logs,tmp}
chown -R mysql:mysql /data/mysql/mysql33076. 创建my.cnf配置文件(见附件)vim /data/mysql/mysql3307/my.cnf7. 初始化数据库
·注意MySQL5.7初始化已经融合到bin/mysqld命令中,通过“--initialize”来完成初始化,更多详细的命令,可以执行下面的命令来查看·/usr/local/mysql/bin/mysqld --verbose --help|less本例中数据库初始化命令如下(它将没有任何的输出,但是你可以从日志进行查看):/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my.cnf --initialize8. 设置环境变量echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile9. 启动MySQL/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my.cnf &10. 修改MySQL的root用户密码
初始完后需要用户自行更改root用户密码,否则执行“mysql -S /tmp/mysql3307.sock -u root -p”将报下面的错误:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
这时候我们需要关闭MySQL数据库,执行下面的命令更改MySQL root的初始化密码:/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3307/my.cnf --skip-grant-tables &
mysql -S /tmp/mysql3307.sock

>update mysql.user set authentication_string=password('3wedu.net') where user='root' and host='localhost';
>flush privileges;
>\q关闭MySQL数据库,然后使用mysqld启动数据库/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my.cnf &启动完毕后,如果直接执行“/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -u root -p”,将报下面的错误:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
这时候需要执行下面的命令对数据库进行密码更改/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -u root -p --connect-expired-password

>set password=password('3wedu.net');
>flush privileges; >\q更改完成后,就可以使用下面的命令直接登录了/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -u root -p11. 附件:my.cnf
#my.cnf
[client]
port            = 3307
socket          = /tmp/mysql3307.sock

[mysql]
prompt="\\u@\\h:\p  \\R:\\m:\\s [\\d]>"
#tee=/data/mysql/mysql_3306/data/query.log
no-auto-rehash
[mysqld_multi]
mysqld     = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user       = zhangdh
password   = zhangdh1113
log        = /data/mysql/mysql3307/logs/multi.log
#tcp-ip

[mysqld]
#misc
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/mysql3307/data
port = 3307
socket = /tmp/mysql3307.sock
event_scheduler = 0
#tmp
tmpdir=/data/mysql/mysql3307/tmp

#timeout
interactive_timeout = 300
wait_timeout = 300

#character set
character-set-server = utf8

open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000

skip-name-resolve = 1
#logs
log-output=file
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
log_warnings = 2
pid-file = mysql.pid
long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1


#binlog
binlog_format = row
server-id = 2003307
log-bin = /data/mysql/mysql3307/logs/mysql-bin
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 0
expire_logs_days = 10

#relay log
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1053,1062

explicit_defaults_for_timestamp=1
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M

#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

#innodb
innodb_buffer_pool_size = 100M
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 500M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 2000
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT

#[mysqld3306]
#port            = 3306
#datadir = /data/mysql/mysql_3306/data
#socket = /tmp/mysql_3306.sock
#tmpdir=/data/mysql/mysql_3306/tmp
#server-id = 2143306
#log-bin = /data/mysql/mysql_3306/logs/mysql-bin

#[mysqld3316]
#port            = 3316
#datadir = /data/mysql/mysql_3316/data
#socket = /tmp/mysql_3316.sock
#tmpdir=/data/mysql/mysql_3316/tmp
#server-id = 2143316
#log-bin = /data/mysql/mysql_3316/logs/mysql-bin

[mysqld_safe]
#malloc-lib=/usr/local/mysql/lib/jmalloc.so 
nice=-19
open-files-limit=65535 查看全部
1.下载MySQL5.7二进制版本
mkdir /opt/mysql
cd /opt/mysql
wget [url]http://downloads.mysql.com/arc ... ar.gz[/url]
2.解压MySQL5.7到/opt/mysql下
tar zxf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
3. 创建一个软连接,方便升级
cd /usr/local ln -s /opt/mysql/mysql-5.7.9-linux-glibc2.5-x86_64 mysql
4. 创建MySQl启动用户和组
groupadd mysql
useradd -d /usr/local/mysql -g mysql -s /sbin/nologin mysql chown -R mysql:mysql /usr/local/mysql
5. 创建基本目录
mkdir -p /data/mysql/mysql3307/{data,logs,tmp} 
chown -R mysql:mysql /data/mysql/mysql3307
6. 创建my.cnf配置文件(见附件)
vim /data/mysql/mysql3307/my.cnf
7. 初始化数据库
·注意MySQL5.7初始化已经融合到bin/mysqld命令中,通过“--initialize”来完成初始化,更多详细的命令,可以执行下面的命令来查看·
/usr/local/mysql/bin/mysqld --verbose --help|less
本例中数据库初始化命令如下(它将没有任何的输出,但是你可以从日志进行查看):
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my.cnf --initialize
8. 设置环境变量
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
9. 启动MySQL
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my.cnf &
10. 修改MySQL的root用户密码
初始完后需要用户自行更改root用户密码,否则执行“mysql -S /tmp/mysql3307.sock -u root -p”将报下面的错误:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
这时候我们需要关闭MySQL数据库,执行下面的命令更改MySQL root的初始化密码:
/usr/local/mysql/bin/mysqld_safe --defaults-file=/data/mysql/mysql3307/my.cnf --skip-grant-tables &
mysql -S /tmp/mysql3307.sock

>update mysql.user set authentication_string=password('3wedu.net') where user='root' and host='localhost';
>flush privileges;
>\q
关闭MySQL数据库,然后使用mysqld启动数据库
/usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql3307/my.cnf &
启动完毕后,如果直接执行“/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -u root -p”,将报下面的错误:
ERROR 1862 (HY000): Your password has expired. To log in you must change it using a client that supports expired passwords.
这时候需要执行下面的命令对数据库进行密码更改
/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -u root -p --connect-expired-password

>set password=password('3wedu.net');
>flush privileges; >\q
更改完成后,就可以使用下面的命令直接登录了
/usr/local/mysql/bin/mysql -S /tmp/mysql3307.sock -u root -p
11. 附件:my.cnf
#my.cnf
[client]
port            = 3307
socket          = /tmp/mysql3307.sock

[mysql]
prompt="\\u@\\h:\p  \\R:\\m:\\s [\\d]>"
#tee=/data/mysql/mysql_3306/data/query.log
no-auto-rehash
[mysqld_multi]
mysqld     = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user       = zhangdh
password   = zhangdh1113
log        = /data/mysql/mysql3307/logs/multi.log
#tcp-ip

[mysqld]
#misc
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/mysql3307/data
port = 3307
socket = /tmp/mysql3307.sock
event_scheduler = 0
#tmp
tmpdir=/data/mysql/mysql3307/tmp

#timeout
interactive_timeout = 300
wait_timeout = 300

#character set
character-set-server = utf8

open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000

skip-name-resolve = 1
#logs
log-output=file
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
log_warnings = 2
pid-file = mysql.pid
long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1


#binlog
binlog_format = row
server-id = 2003307
log-bin = /data/mysql/mysql3307/logs/mysql-bin
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 0
expire_logs_days = 10

#relay log
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1053,1062

explicit_defaults_for_timestamp=1
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M

#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1

#innodb
innodb_buffer_pool_size = 100M
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 500M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 2000
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT

#[mysqld3306]
#port            = 3306
#datadir = /data/mysql/mysql_3306/data
#socket = /tmp/mysql_3306.sock
#tmpdir=/data/mysql/mysql_3306/tmp
#server-id = 2143306
#log-bin = /data/mysql/mysql_3306/logs/mysql-bin

#[mysqld3316]
#port            = 3316
#datadir = /data/mysql/mysql_3316/data
#socket = /tmp/mysql_3316.sock
#tmpdir=/data/mysql/mysql_3316/tmp
#server-id = 2143316
#log-bin = /data/mysql/mysql_3316/logs/mysql-bin

[mysqld_safe]
#malloc-lib=/usr/local/mysql/lib/jmalloc.so 
nice=-19
open-files-limit=65535

3分钟搞定MySQL5.6安装

MySQLzhangdh 发表了文章 • 2 个评论 • 632 次浏览 • 2015-12-22 16:43 • 来自相关话题

1. 下载MySQL二进制版本mkdir /opt/mysql
cd /opt/mysql
wget [url]http://cdn.mysql.com/archives/ ... ar.gz[/url]2. 将mysql解压到/opt/mysql下tar zxvf mysql-5.6.27-linux-glibc2.5-x86_64.tar.gz3. 创建一个软链,便于版本升级cd /usr/local/
ln -s /opt/mysql/mysql-5.6.27-linux-glibc2.5-x86_64 mysql4. 创建MySQL启动用户groupadd mysql
useradd -g mysql -s /sbin/nologin -d /usr/local/mysql mysql5. 创建基本的目录mkdir -p /data/mysql/mysql3306/{data,logs,tmp}
chown -R mysql:mysql /data/mysql/mysql33066. 创建/etc/my.cnf配置文件(见附件)

7. 做MySQL初始化cd /usr/local/mysql
./scripts/mysql_install_db8. 创建一个启动脚本cp support-files/mysql.server /etc/init.d/mysql9. 启动和关闭/etc/init.d/mysql start|stop|restart10. 配置文件参考:
#my.cnf
[client]
port            = 3306
socket          = /tmp/mysql.sock
[mysql]
prompt="\\u@\\h:\p  \\R:\\m:\\s [\\d]>"
#tee=/data/mysql/mysql3306/data/query.log
no-auto-rehash
[mysqld]
#misc
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/mysql3306/data
port = 3306
socket = /tmp/mysql.sock
event_scheduler = 0
#tmp
tmpdir=/data/mysql/mysql3306/tmp
#timeout
interactive_timeout = 300
wait_timeout = 300
#character set
character-set-server = utf8
open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000
skip-name-resolve = 1
#logs
log-output=file
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
log_warnings = 2
pid-file = mysql.pid
long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1
#binlog
binlog_format = row
server-id = 1003306
log-bin = /data/mysql/mysql3306/logs/mysql-bin
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 0
expire_logs_days = 10
#relay log
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1053,1062
explicit_defaults_for_timestamp=1
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M
#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
#innodb
innodb_buffer_pool_size = 100M
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 500M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 2000
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT
[mysqld_safe]
#malloc-lib=/usr/local/mysql/lib/jmalloc.so
nice=-19
open-files-limit=65535 查看全部
1. 下载MySQL二进制版本
mkdir /opt/mysql
cd /opt/mysql
wget [url]http://cdn.mysql.com/archives/ ... ar.gz[/url]
2. 将mysql解压到/opt/mysql下
tar zxvf mysql-5.6.27-linux-glibc2.5-x86_64.tar.gz
3. 创建一个软链,便于版本升级
cd /usr/local/ 
ln -s /opt/mysql/mysql-5.6.27-linux-glibc2.5-x86_64 mysql
4. 创建MySQL启动用户
groupadd mysql 
useradd -g mysql -s /sbin/nologin -d /usr/local/mysql mysql
5. 创建基本的目录
mkdir -p /data/mysql/mysql3306/{data,logs,tmp}
chown -R mysql:mysql /data/mysql/mysql3306
6. 创建/etc/my.cnf配置文件(见附件)

7. 做MySQL初始化
cd /usr/local/mysql
./scripts/mysql_install_db
8. 创建一个启动脚本
cp support-files/mysql.server /etc/init.d/mysql
9. 启动和关闭
/etc/init.d/mysql start|stop|restart
10. 配置文件参考:
#my.cnf
[client]
port            = 3306
socket          = /tmp/mysql.sock
[mysql]
prompt="\\u@\\h:\p  \\R:\\m:\\s [\\d]>"
#tee=/data/mysql/mysql3306/data/query.log
no-auto-rehash
[mysqld]
#misc
user = mysql
basedir = /usr/local/mysql
datadir = /data/mysql/mysql3306/data
port = 3306
socket = /tmp/mysql.sock
event_scheduler = 0
#tmp
tmpdir=/data/mysql/mysql3306/tmp
#timeout
interactive_timeout = 300
wait_timeout = 300
#character set
character-set-server = utf8
open_files_limit = 65535
max_connections = 100
max_connect_errors = 100000
skip-name-resolve = 1
#logs
log-output=file
slow_query_log = 1
slow_query_log_file = slow.log
log-error = error.log
log_warnings = 2
pid-file = mysql.pid
long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
log-slow-slave-statements = 1
#binlog
binlog_format = row
server-id = 1003306
log-bin = /data/mysql/mysql3306/logs/mysql-bin
binlog_cache_size = 4M
max_binlog_size = 1G
max_binlog_cache_size = 2G
sync_binlog = 0
expire_logs_days = 10
#relay log
skip_slave_start = 1
max_relay_log_size = 1G
relay_log_purge = 1
relay_log_recovery = 1
log_slave_updates
#slave-skip-errors=1032,1053,1062
explicit_defaults_for_timestamp=1
#buffers & cache
table_open_cache = 2048
table_definition_cache = 2048
table_open_cache = 2048
max_heap_table_size = 96M
sort_buffer_size = 2M
join_buffer_size = 2M
thread_cache_size = 256
query_cache_size = 0
query_cache_type = 0
query_cache_limit = 256K
query_cache_min_res_unit = 512
thread_stack = 192K
tmp_table_size = 96M
key_buffer_size = 8M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
bulk_insert_buffer_size = 32M
#myisam
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
#innodb
innodb_buffer_pool_size = 100M
innodb_buffer_pool_instances = 1
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 64M
innodb_log_file_size = 500M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
innodb_rollback_on_timeout
innodb_status_file = 1
innodb_io_capacity = 2000
transaction_isolation = READ-COMMITTED
innodb_flush_method = O_DIRECT
[mysqld_safe]
#malloc-lib=/usr/local/mysql/lib/jmalloc.so
nice=-19
open-files-limit=65535