linux安装MySQL
1:下载MySQL:get http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
我的下载文件夹为: /usr/local/mysql
2:解压到你要安装的文件夹:tar -zxvf mysql.gz -C /usr/local/mysql/mysql
3:安装
4:创建一个mysql用户和组
命令:groupadd mysql
useradd -r -g mysql -s /bin/false mysql
5:更改mysql目录下所有的目录及文件夹所属组合用户
cd /usr/local/mysql
chown -R mysql mysql/
chgrp -R mysql mysql/
6安装链接库文件:
yum install libaio-devel.x86_64
7:安装和初始化数据库
进入mysql的bin文件夹下。
mysqld --initialize --user=mysql --basedir=/usr/local/mysql/mysql --datadir=/usr/local/mysql/mysql/data
最后会生成一个初始的随机化的密码。记住他。以后改密码的时候会用。
密码是localhost:后面的字符串。
8:执行bin/mysql_ssl_rsa_setup --datadir=/usr/local/mysql/mysql/data
9:复制my-default.cnf到系统配置里 cp my-default.cnf /etc/my.cnf
10:修改这个配置文件如下内容
#dvice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
# 一般配置选项
basedir = /usr/mysql
datadir = /usr/mysql/data
port = 3306
#socket = /temp/mysqld.sock
socket = /var/run/mysqld/mysqld.sock
character-set-server=utf8
#下面是可选项,要不要都行,如果出现启动错误,则全部注释掉,保留最基本的配置选项,然后尝试添加某些配置项后启动,检测配置项是否有误
back_log = 300
max_connections = 3000
max_connect_errors = 50
table_open_cache = 4096
max_allowed_packet = 32M
#binlog_cache_size = 4M
max_heap_table_size = 128M
read_rnd_buffer_size = 16M
sort_buffer_size = 16M
join_buffer_size = 16M
thread_cache_size = 16
query_cache_size = 128M
query_cache_limit = 4M
ft_min_word_len = 8
thread_stack = 512K
transaction_isolation = REPEATABLE-READ
tmp_table_size = 128M
#log-bin=mysql-bin
long_query_time = 6
server_id=1
innodb_buffer_pool_size = 1G
innodb_thread_concurrency = 16
innodb_log_buffer_size = 16M
innodb_log_file_size = 512M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = on
[mysqldump]
quick
max_allowed_packet = 32M
[mysql]
no-auto-rehash
socket = /var/run/mysqld/mysqld.sock
default-character-set=utf8
safe-updates
[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit = 8192
[client]
loose-default-character-set = utf8
11:实现在任意路径利用server mysql stop(start)启动或者停止mysql :cp mysql.server /etc/init.d/mysqld
12:登陆MySQL:./mysql -uroot -p这时候需要用到最开始的密码
13:修改root密码:SET PASSWORD = PASSWORD('root');
14:设置远程连接:update user set host = '%' where user = 'root';
15:关闭mysql
16重启mysql:
/etc/init.d/mysqld restart或者server mysql restart
17:然后可以在sqlyog或者axure测试远程连接
如果失败的话一般是没配置好路径。在vim /etc/init.d/mysqld和mysql下的conf下的server配置环境有问题下修改文件配置。