Mysql
先卸载mariadb
查看mariadb包信息
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-* #包信息,需要强制卸载
卸载完后装MySQL
1 、安装yum源
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
yum repolist enabled | grep "mysql.-community."
2 、安装mysql
yum -y install mysql-community-server
看到有 Installed.....complete!就是安装完成了
3、 启动和设置开机自启
# 启动和查看启动状态
systemctl start mysqld
systemctl status mysqld
# 开机启动
systemctl enable mysqld
systemctl daemon-reload
4、修改默认root密码
可以使用mysql_secure_installation命令直接修改密码也可以通过以下命令查看密码然后修改
grep 'temporary password' /var/log/mysqld.log
更新密码
#mysql -u root -p
>上面查询到的密码
mysql>set password for root@localhost = password('123');
5、mysql用户设置远程访问权限
方法1、改表法:登陆mysql后,更改“mysql”数据库里的“user”表里的“host”项,将“localhost”改“%”
mysql>use mysql;
mysql>update user set host ='%' where user ='root';
mysql>select host,user from user;
mysql>FLUSH PRIVILEGES
方法2: 在mysql下输入grant all privileges on *.* to root@'%' identified by "111111";即可实现可以远程访问本机的mysql,注:"111111"为mysql的密码
方法2、授权法:假设允许用户username通过密码password从远程连接到mysql服务器
mysql>GRANT ALL RRIVILEGES ON *.* TO username@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
6、安装目录结构
数据库目录:/var/lib/mysql/
配置文件:/usr/share/mysql(mysql.server命令及配置文件)
相关命令:/usr/bin(mysqladmin、mysqldump等命令)(*mysql的一种安全启动方式:/usr/bin/mysqld_safe --user=root &)
启动脚本:/etc/rc.d/init.d/
7、复制mysql数据库
源数据库名:source_db 用户名:root 密码:xxxxxx
目标数据库名:target_db 用户名:root 密码:xxxxxx 所在主机:221.218.9.41
shell>mysqldump source_db -uroot -pxxxxxx --opt | mysql target_db -uroot -pxxxxxx -h 221.218.9.41
安装 Nginx
yum 安装nginx
sudo yum -y install nginx # 安装 nginx
配置目录:/etc/nginx
如果提示错误需要加载一下云源
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
启动nginx
systemctl start nginx
停止nginx
systemctl stop nginx
设置自启动
sudo chkconfig nginx on
systemctl enable nginx.service