mysql5.7.11解压版安装配置

Mysql的安装与配置

我们还需要修改一下配置文件(如果没有配置,之后启动的时候就错误2 系统找不到文件),mysql-5.7.11默认的配置文件是在mysql/my-default.ini,或者自己建立一个my.ini文件,

My.ini参考内容

[mysqld]

basedir = "D:wampservermysql"

datadir = "D:wampservermysqldata"

port=3306

character-set-server=utf8

character_set_filesystem= binary

[client]

port=3306

default-character-set = utf8

[mysqld_safe]

timezone="CST"

[mysql]

default-character-set=utf8

打开一个cmd.exe,将目录切换到D:MySQL-5.6.13in,运行:mysqld -install ,提示服务安装成功!运行services.msc一看,确实有一个名为MySQL的服务了,启动它。

或者输入 net start mysql

如果无法启动,没有报任何错位信息,则可能是mysql,里面data的原因

打开mysql的安装目录,如果里面没有data文件,则需要在bin中cmd,mysqld --initialize-insecure,生成一个以root为用户名,空密码的用户数据


mysqld --initialize-insecure自动生成无密码的root用户,mysqld --initialize自动生成带随机密码的root用户。data文件夹不为空或者存在是不能执行这个命令的。可以先删除data文件夹或者移走

mysqld --initialize自动生成带随机密码可以在mysql/data里面的后缀名是.err的文件中查看(错误日志)

注:

mysqld --console 启动 可以显示出启动错误信息

在UNIX下

shell> bin/mysqld --initialize --user=mysql

shell> bin/mysqld --initialize-insecure --user=mysql

很多用户开始使用MySQL,但会出现图示的错误。

这是因为没有配置环境变量所致。配置环境变量很简单:

我的电脑->属性->高级->环境变量

选择PATH,在其后面添加: 你的mysql bin文件夹的路径 (如:C:Program FilesMySQLMySQL Server 5.6in )

PATH=.......;C:Program FilesMySQLMySQL Server 5.6in (注意是追加,不是覆盖)

在mysql中输入select version()可以查看mysql的版本信息

If you used but not to initialize the data directory, connect to the server as root using the random password that the server generated during the initialization sequence:

shell> mysql -u root -p

Enter password:(enter the random root password here)

If you used to initialize the data directory, connect to the server as root without a password:

shell> mysql -u root --skip-password

1. After connecting, assign a new root password:

mysql> ALTER USER root@localhost IDENTIFIED BY new_password;

set password for root@localhost = password(mysqlroot);

具体参考:

http://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html



经验分享 程序员 微信小程序 职场和发展