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 mysql2, 安装
先检查有无mysql用户:cat /etc/group | grep mysql
cat /etc/passwd | grep mysql
如果无则添加mysql用户。
groupadd mysql
useradd -r -g mysql mysqlmkdir /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
输入:root123show 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 –dp开发云主机域名ort 3306 -j ACCEPT
然后执行 service iptables restart
相关推荐: 如何基于生产环境mysql 5.6.25主从部署新的mysql从库操作指南
1,背景需求 由于现网的环境,经过近期监控,发现MYSQL主库的IO读写压力比较大,需要部署新的MYSQL从库,进一步分摊MYSQL主库的压力,以及现存MYSQL从库的读负载。为了减少对于MYSQL主库的IO读取性能冲击,采用基于MYSQL现存从库构建新的MY…
免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。