Centos 升級(jí)MySQL版本或者Yum安裝Mysql5.6
- 1.從MySQL Yum倉(cāng)庫(kù)下載最新的rpm文件:
http://dev.mysql.com/downloads/repo/yum/
CentOS 6
http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm - 2.yum remove mysql mysql-*
- 3.mysql-community-release-el6-5.noarch.rpm
- 4.yum localinstall mysql-community-release-el6-5.noarch.rpm
- 5.可以通過(guò)下面的命令來(lái)確認(rèn)這個(gè)倉(cāng)庫(kù)被成功添加:
yum repolist enabled | grep "mysql.-community." - 6.yum install mysql-community-server
設(shè)置currenttime
http://www.metsky.com/archives/118.html
參考文件:
http://blog.csdn.net/shootyou/article/details/8236886
記得刪除老版本的/etc/my.conf,/var/lib/mysql, 或者備份老版本的mysql
否則可能會(huì)起動(dòng)不起來(lái)
http://www.th7.cn/db/mysql/201408/66691.shtml
修改用戶密碼:
update mysql.user set password=password("新密碼") where User="root";
flush privileges;
// windows
修改登錄密碼 MySQL默認(rèn)沒(méi)有密碼,安裝完畢增加密碼的重要性是不言而喻的。
1、命令 /usr/bin/mysqladmin -u root password 'new-password'**
格式:
mysqladmin -u用戶名 -p舊密碼 password 新密碼**
2、例子 例1:給root加個(gè)密碼123456。
鍵入以下命令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
創(chuàng)建數(shù)據(jù)庫(kù):
CREATE DATABASE `test2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
修改my.cnf文件(mysql 減少內(nèi)存使用)
# Example mysql config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it's important that the mysqld deamon
# doesn't use much resources.
#
# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /var/lib/mysql) or
# ~/.my.cnf to set user-specific options.
#
# One can in this file use all long options that the program supports.
# If you want to know which options a program support, run the program
# with --help option.
# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /var/run/mysqld/mysqld.sock
character-set-server=utf8
key_buffer = 16K
query_cache_limit = 256K
query_cache_size = 4M
max_allowed_packet = 1M
max_connections = 16
thread_concurrency = 2
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
performance_schema_max_table_instances=400
table_definition_cache=400
table_open_cache=256
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
#safe-updates
[isamchk]
key_buffer = 8M
sort_buffer_size = 8M
[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M
[mysqlhotcopy]
interactive-timeout
# Uncomment the following if you want to log updates
#log-bin
# Uncomment the following if you are NOT using BDB tables
#skip-bdb
# Uncomment the following if you are using Innobase tables
#innodb_data_file_path = ibdata1:100M
#innodb_data_home_dir = /var/lib/mysql/
#innodb_log_group_home_dir = /var/lib/mysql/
#innodb_log_arch_dir = /var/lib/mysql/
#set-variable = innodb_mirrored_log_groups=1
#set-variable = innodb_log_files_in_group=3
#set-variable = innodb_log_file_size=5M
#set-variable = innodb_log_buffer_size=8M
#innodb_flush_log_at_trx_commit=1
#innodb_log_archive=0
#set-variable = innodb_buffer_pool_size=16M
#set-variable = innodb_additional_mem_pool_size=2M
#set-variable = innodb_file_io_threads=4
#set-variable = innodb_lock_wait_timeout=50
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
字符編碼
查看字符編碼: status
1.關(guān)于MySQL字符集
MySQL的字符集支持(Character Set Support)有兩個(gè)方面:
字符集(Character set)和排序方式(Collation)。
MySQL對(duì)于字符集的支持細(xì)化到四個(gè)層次: 服務(wù)器(server),數(shù)據(jù)庫(kù)(database),數(shù)據(jù)表(table)和連接(connection)。
MySQL對(duì)于字符集的指定可以細(xì)化到一個(gè)數(shù)據(jù)庫(kù),一張表,一列,應(yīng)該用什么字符集。
2.查看MySQL字符集
2.1.查看字符集的設(shè)置
mysql> show variables like 'character_set_%';
2.2.查看字符集排序設(shè)置
mysql> show variables like 'collation_%';
3.修改MySQL字符集
3.1修改服務(wù)器級(jí)別字符集
a.臨時(shí)修改
mysql>SET GLOBAL character_set_server=utf8;
b.永久修改
打開(kāi)/etc/mysql/my.cnf,在[mysqld]后添加character-set-server=utf8
3.2修改數(shù)據(jù)庫(kù)級(jí)
a. 臨時(shí)更改
mysql>SET GLOBAL character_set_database=utf8;
b. 永久更改
改了服務(wù)器級(jí)就可以了
3.3修改表級(jí)
mysql>ALTER TABLE table_name DEFAULT CHARSET utf8; 更改了后永久生效
3.4修改列級(jí)修改示例
mysql>ALTER TABLE `products` CHANGE `products_model` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; 更改了后永久生效
3.5更改連接字符集
a. 臨時(shí)更改:mysql> SET GLOBAL character_set_client;
b. 永久更改:打開(kāi)/etc/mysql/my.cnf,在[client]后添加default-character-set=utf8
Notice:3.1和3.5需要重啟mysql: service mysql restart
重起mysql
service mysqld restart
轉(zhuǎn):http://www.blogjava.net/nkjava/archive/2014/11/21/420406.html