linux系統mysql安裝配置
linux下使用yum安裝mysql一.mysql安裝查看有沒有安裝過mysql老版本:yum list installed mysql*rpm -qa | grep mysql*安裝mysqlyum install mysql-servermysql-devel mysql注意:這裡使用預設的yum 源只能安裝到mysql-5.1.73-3.el6_5.x86_64版本,想要安裝最新的mysql資料庫的話需要使用另外的安裝源
二.MySQL 5.5.x安裝
1、安裝MySQL 5.5.x的yum源:
rpm -Uvh http://repo.webtatic.com/yum/CentOS/5/latest.rpm
2、安裝MySQL用戶端的支援包:
yum install libmysqlclient15 --enablerepo=webtatic
3、卸載MySQL老版本的軟體包:
yum remove mysql mysql-*
4、安裝MySQL 5.5的用戶端和服務端:
yum install mysql55 mysql55-server --enablerepo=webtatic //--enablerepo=webtatic 指定使用第一步下載的yum源進行下載安裝
注意:這裡yum安裝的時候可能會報lib缺失,需要按照需要安裝必要的lib庫。
三.mysql啟動&&停止啟動mysql服務:service mysqld start或者/etc/init.d/mysqld start開機啟動:
chkconfig -add mysqld,查看開機啟動設定是否成功chkconfig --list | grep mysql*停止:service mysqld stop四.基本配置
1.修改root管理員密碼:mysqladmin -u root password "你想設定的密碼"
2.設定遠端存取mysql增加許可權:mysql庫中的user表新增一條記錄host為“%”,user為“root”。
grantallon*.*to‘root’@’%’;
flush privileges;3. MySQL的幾個重要目錄預設資料庫目錄,可以自行修改
/var/lib/mysql/
mysql記錄檔
/var/log/mysql.log(預設情況下)
設定檔/etc/my.cnf
附上我的my.cnf,供大家參考
- [client]
- socket=/var/lib/mysql/mysql.sock
- default-character-set=utf8
- [client]
- socket=/var/lib/mysql/mysql.sock
- default-character-set=utf8
- [mysqld]
- innodb_file_per_table=1
- default-character-set=utf8
- init_connect='SET NAMES utf8'
- datadir=/database/mysql
- socket=/var/lib/mysql/mysql.sock
- skip-external-locking
- user=mysql
- general_log_file=/database/mysql/log/mysql.log
- long_query_time=1
- slow_query_log=1
- slow_query_log_file=/database/mysql/log/slowquery.log
- key_buffer_size = 128M
- max_allowed_packet = 1M
- table_open_cache = 512
- sort_buffer_size = 4M
- read_buffer_size = 2M
- read_rnd_buffer_size = 8M
- myisam_sort_buffer_size = 64M
- thread_cache_size = 8
- query_cache_size = 32M
- query_prealloc_size = 64M
- join_buffer_size = 128M
- # Default to using old password format for compatibility with mysql 3.x
- # clients (those using the mysqlclient10 compatibility package).
- old_passwords=1
- # Disabling symbolic-links is recommended to prevent assorted security risks;
- # to do so, uncomment this line:
- # symbolic-links=0
- innodb_buffer_pool_size=64M
- [mysqld_safe]
- log-error=/database/mysql/log/mysql.error.log
- pid-file=/var/run/mysqld/mysqld.pid
- [myisamchk]
- key_buffer_size = 128M
- sort_buffer_size = 128M
- read_buffer = 2M
- write_buffer = 2M