- 检查mysql是否安装旧版,如果安装,利用
rpm -e
和zypper rm
删除旧版 - 下载新版mysql相应rpm安装包,利用rpm安装,
rpm -ivh *
- 修改默认配置文件位置至/etc下
$ cp /usr/share/mysql/my-default.cnf /etc/my.cnf
- 初始化mysql设置密码等
$ mysql -u root $ use mysql mysql> update user set password=password('123456') where user='root'; mysql> update user set host='%' where user='root' and host='$hostname'; mysql> flush privileges; mysql> exit
- 重启mysql
$ service mysql restart
- 设置检查开机自启动
$ chkconfig mysql onsystemctl list-unit-files | grep mysql $ systemctl list-unit-files | grep mysql
- 配置mysql存放路径,编码等优化选项
$ vi /etc/my.cnf [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... datadir = /var/lib/mysql port = 3306 # server_id = ..... socket = /var/lib/mysql/mysql.sock # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. join_buffer_size = 128M sort_buffer_size = 2M read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES character_set_server=utf8 character_set_client=utf8 collation-server=utf8_general_ci #(注意linux下mysql安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写) lower_case_table_names=1 #(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; ) max_connections=1000
CENTOS安装mysql
- 基本步骤类似,初始化时略微不同
$ /usr/bin/mysql_install_db $ service mysql start $ cat /root/.mysql_secret #查看root账号密码 The random password set for the root user at Wed Dec 11 23:32:50 2013 (local time): qKTaFZnl $ mysql -uroot –pqKTaFZnl mysql> SET PASSWORD = PASSWORD('123456'); #设置密码为123456 mysql> exit $ mysql -uroot -p123456
0 条评论