linux下使用yum安装mysql
一.mysql安装
查看有没有安装过mysql老版本:
yum list installed mysql*
rpm -qa | grep mysql*
安装mysql
yum install mysql-server mysql-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
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”。
grant all on *.* 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
阅读(651) | 评论(0) | 转发(0) |