Mysql 安裝 配置
Centos 升級MySQL版本或者Yum安裝Mysql5.6
- 1.從MySQL Yum倉庫下載最新的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.可以通過下面的命令來確認這個倉庫被成功新增:
yum repolist enabled | grep "mysql.-community." - 6.yum install mysql-community-server
設定currenttime
http://www.metsky.com/archives/118.html
參考檔案:
http://blog.csdn.net/shootyou/article/details/8236886
記得刪除老版本的/etc/my.conf,/var/lib/mysql, 或者備份老版本的mysql
否則可能會起動不起來
http://www.th7.cn/db/mysql/201408/66691.shtml
修改使用者密碼:
update mysql.user set password=password("新密碼") where User="root";
flush privileges;
// windows
修改登入密碼 MySQL預設沒有密碼,安裝完畢增加密碼的重要性是不言而喻的。
1、命令 /usr/bin/mysqladmin -u root password 'new-password'**
格式:
mysqladmin -u使用者名稱 -p舊密碼 password 新密碼**
2、例子 例1:給root加個密碼123456。
鍵入以下命令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
建立資料庫:
CREATE DATABASE `test2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
修改my.cnf檔案(mysql 減少記憶體使用)
# 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.關於MySQL字符集
MySQL的字符集支援(Character Set Support)有兩個方面:
字符集(Character set)和排序方式(Collation)。
MySQL對於字符集的支援細化到四個層次: 伺服器(server),資料庫(database),資料表(table)和連線(connection)。
MySQL對於字符集的指定可以細化到一個資料庫,一張表,一列,應該用什麼字符集。
2.檢視MySQL字符集
2.1.檢視字符集的設定
mysql> show variables like 'character_set_%';
2.2.檢視字符集排序設定
mysql> show variables like 'collation_%';
3.修改MySQL字符集
3.1修改伺服器級別字符集
a.臨時修改
mysql>SET GLOBAL character_set_server=utf8;
b.永久修改
開啟/etc/mysql/my.cnf,在[mysqld]後新增character-set-server=utf8
3.2修改資料庫級
a. 臨時更改
mysql>SET GLOBAL character_set_database=utf8;
b. 永久更改
改了伺服器級就可以了
3.3修改表級
mysql>ALTER TABLE table_name DEFAULT CHARSET utf8; 更改了後永久生效
3.4修改列級修改示例
mysql>ALTER TABLE `products` CHANGE `products_model` VARCHAR( 20 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; 更改了後永久生效
3.5更改連線字符集
a. 臨時更改:mysql> SET GLOBAL character_set_client;
b. 永久更改:開啟/etc/mysql/my.cnf,在[client]後新增default-character-set=utf8
Notice:3.1和3.5需要重啟mysql: service mysql restart
重起mysql
service mysqld restart
轉:http://www.blogjava.net/nkjava/archive/2014/11/21/420406.html
相關文章
- MySQL安裝配置MySql
- MYSQL + MHA +keepalive + VIP安裝配置(一)--MYSQL安裝配置MySql
- 【MySQL】安裝與配置MySql
- MySQL安裝與配置MySql
- 3安裝配置mysqlMySql
- mysql安裝及配置MySql
- MySQL-安裝配置篇MySql
- mac MYSQL安裝和配置MacMySql
- mysql + keepalived 安裝配置MySql
- MySQL免安裝版配置MySql
- solaris 10 mysql 安裝 配置MySql
- MySQL 免安裝版配置MySql
- 【mysql】CentOS離線安裝配置MySqlMySqlCentOS
- 【Mysql】Windows下安裝和配置MysqlMySqlWindows
- MySQL安裝之二_安裝配置泥潭版MySql
- MYSQL + MHA +keepalive + VIP安裝配置(三)--keepalived安裝配置MySql
- Mysql for Linux安裝配置之—— 原始碼安裝MySqlLinux原始碼
- MySQL安裝之一_安裝配置順利版MySql
- Windows 安裝並配置 MySQL 5.6WindowsMySql
- LNMP--mysql php安裝配置LNMPMySqlPHP
- Centos7 安裝配置MysqlCentOSMySql
- Mysql安裝及基礎配置MySql
- mysql 非安裝版的配置MySql
- MySql綠色版安裝配置MySql
- MySQL - 安裝時的安全配置MySql
- Mysql for Linux安裝配置之—— rpm(bundle)安裝MySqlLinux
- Ubuntu 18.04 安裝配置 MySQL 5.7UbuntuMySql
- Mysql安裝與配置_win10MySqlWin10
- windows安裝及配置mysql5.7WindowsMySql
- 【Mysql】keepalive的安裝與配置MySql
- MySQL優化-安裝配置優化MySql優化
- CentOs中mysql的安裝與配置CentOSMySql
- MySQL的下載、安裝和配置MySql
- Mysql for Linux安裝配置之——二進位制安裝MySqlLinux
- MySQL系列第一篇:MySQL安裝配置MySql
- MySQL的簡單安裝配置(免安裝zip版,版本5.7.21)MySql
- MySQL 主從複製安裝部署配置MySql
- macOS下MySQL 8.0 安裝與配置教程MacMySql