mysql安装配置

来源:互联网 发布:唐筛检查结果数据分析 编辑:程序博客网 时间:2024/06/06 00:57
windows下mysql安装配置:
下载:http://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.14-winx64.zip
1.将mysql-5.7.14-winx64.zip解压版压缩包拷贝到D:\developerInstall\MySQL路径下
2.解压到当前文件夹
3.将解压出来的文件夹重命名为MySQLServer5.7
4.进入MySQLServer5.7文件夹,重命名my-default.ini为my.ini,打开my.ini文件编辑:
# basedir = .....
# datadir = .....
修改为:
basedir = D:\developerInstall\MySQL\MySQLServer5.7
datadir = D:\developerInstall\MySQL\MySQLServer5.7\data
5:以管理员身份运行cmd命令行程序
6.执行下面的命令安装mysql服务:
d:
cd D:\developerInstall\MySQL\MySQLServer5.7\bin
mysqld --initialize-insecure --user=mysql#创建data目录
mysqld -install
7.执行下面的命令启动mysql服务:
net start mysql
8.登录mysql:(第一次登录没有密码)
mysql -u root -p
9.修改密码为root:
set password = password('root');
10.退出重新登录:
exit

mysql -uroot -proot







linux安装配置mysql:

yum list installed | grep mysql#查看是否已经安装了mysql
yum -y remove mysql-libs.x86_64#卸载已安的mysql
yum list | grep mysql 或 yum -y list mysql*#查看当前yum源上的mysql版本信息
yum -y install mysql-server mysql mysql-devel#安装mysql
rpm -qi mysql-server#查看安装的mysql的版本信息
vi /etc/my.cnf

character_set_server=utf8
init_connect='SET NAMES utf8'

service mysqld start或者/etc/init.d/mysqld start启动mysql
chkconfig --add mysqld#加入服务自起动
chkconfig --list | grep mysqld#查看开机启动
chkconfig --level 2345 mysqld on#设置mysqld服务在2345运行级别自启动,可输入上条命再次检查自启动
service mysqld stop 或者 /etc/init.d/mysqld stop#关闭mysql服务

mysqladmin -u root password 123456#为root用户设备密码为123456
mysql -u root -p123456#登录

忘记密码:
vi /etc/my.cnf
skip-grant-tables#一定要放在[mysqld]这一行的下一行

service mysqld restart  #重启MySQL服务

mysql -uroot -p#回车,提示输入密码,不要输入直接回车
update mysql.user set password=password('1234567') where User="root" and Host="localhost";#修改密码为1234567
flush privileges;  #刷新系统授权表
vi /etc/my.cnf
#skip-grant-tables#注释掉刚加入的那一行
service mysqld restart#重启mysql服务
mysql -uroot -p1234567#使用新密码登录



允许远程登录:

vi /etc/sysconfig/iptables#防火墙配置
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT#加入一行,放行3306端口
-A INPUT -m state --state NEW -m udp -p udp --dport 161 -j ACCEPT
service iptables restart#重启防火墙使用配置生效

grant all privileges on *.* to root@"%" identified by '123456' with grant option; #这行里面需要修改的就是密码'123456'
flush privileges;



参考:

http://www.cr173.com/html/50452_1.html

0 0
原创粉丝点击