您好,登录后才能下订单哦!
Mysql学习
Linux上安装mysql
1, 下载安装包Server version: 5.7.28 MySQL Community Server (GPL)
下载路径:https://dev.mysql.com/downloads/mysql/
从mysql-5.7.28-linux-glibc2.12-x86_64.tar获取mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz和mysql-test-5.7.28-linux-glibc2.12-x86_64.tar.gz , test暂时还未用只上传安装:mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
解压文件: tar xzvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz /usr/local/
重命名文件:mv mysql-5.7.28-linux-glibc2.12-x86_64 mysql
2, 安装
先检查有无mysql用户:cat /etc/group | grep mysql
cat /etc/passwd | grep mysql
如果无则添加mysql用户。
groupadd mysql
useradd -r -g mysql mysql
mkdir /usr/local/mysql/data
chown -R mysql:mysql /usr/local/mysql
配置/etc/my.cnf文件:
[mysqld]
datadir=/usr/local/mysql/data
basedir=/usr/local/mysql
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=400
innodb_file_per_table=1
#表名大小写不明感,敏感为
lower_case_table_names=1
user=mysql
socket=/mysqllog/mysql.sock
character-set-server=utf8
#skip-grant-tables
[mysql]
default-character-set=utf8
socket=/mysqllog/mysql.sock
[mysqld_safe]
log-error=/mysqllog/mysqld.log
pid-file=/mysqllog/mysqld.pid
#datadir=/usr/local/mysql/data
[cient]
port=3306
socket=/mysqllog/mysql.sock
创建日志文件夹
mkdir mysqllog
vi mysqld.log 新建mysqld.log
chown -R mysql:mysql /mysqllog
chmod 755 /mysqllog/mysqld.log
初始化:
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
添加软链接
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
重启服务
service mysql restart
密码删除 /etc/init.d/my.cnf添加skip-grant-tables
然后直接登录mysql 替换密码
update mysql.user set authentication_string=password('root123') where user='root'; 执行后flush privileges;
再删除skip-grant-tables
重启服务mysql
连接mysql
输入:mysql -u root -p
输入:root123
show databases;
use mysql
添加远程访问
开启某一个IP
grant all privileges on . to 'root'@'192.168.0.1' identified by 'password' with grant option;
开启所有
grant all privileges on . to 'root'@'%' identified by 'password' with grant option;
记着刷新mysql机制
flush privileges;
quit;
试着远程连接访问…… 如果访问不通 mysql服务器可能防火墙开启未释放3306端口
防火墙释放添加
/etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
然后执行 service iptables restart
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。