linux下使用yum安装mysql
一.mysql安装
复制代码代码示例:
yum list installed mysql*
rpm -qa | grep mysql*
安装mysql
复制代码代码示例:
注意:这里使用默认的yum 源只能安装到mysql-5.1.73-3.el6_5.x86_64版本,想要安装最新的mysql数据库,则需要使用另外的安装源。
二.MySQL 5.5.x安装
复制代码代码示例:
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启动&&停止
复制代码代码示例:
service mysqld start或者/etc/init.d/mysqld start
开机启动:
复制代码代码示例:
chkconfig -add mysqld,查看开机启动设置是否成功chkconfig --list | grep mysql*
停止:
复制代码代码示例:
service mysqld stop
四.基本配置
复制代码代码示例:
mysqladmin -u root password "你想设置的密码"
2.设置远程访问
复制代码代码示例:
grant all on *.* to ‘root’@’%’;
flush privileges;
3. MySQL的几个重要目录
五,my.cnf配置文件
复制代码代码示例:
[client]
(责任编辑:IT)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 |