Recently, I wanted to study the server side. First, I installed a Mysql database. As a result, the latest version of the official website (5.7) confirmed that it was difficult to install. As a result, according to online inquiries and asking friends, I found that the latest version 5.6 is better to use, so I installed it smoothly. The tutorial is as follows:
one. tool
Win7 64-bit operating system
two. step
Step 1: Download the installation package
Download address: http://www.mysql.com/
The platform defaults to Windows.
Confirm whether your computer is x86 or x64, click download.
Step 2: Unzip
After unzipping, you can rename the folder and put it in a suitable location. I renamed the folder to MySQL Server 5.6 and put it in the D:\Program Files\MySQL path. Of course, you can put it anywhere you want.
The third step: configuration (do not rush to use, it is best to configure first)
After configuring the environment variable PATH, you can open mysql later without switching directories.
Process: Computer -> System Properties -> Advanced System Configuration -> Environment Variables
Select PATH and add: the path of your mysql bin folder (eg: mine is: D:\Program Files\MySQL\MySQL Server 5.6\bin ) The modified PATH is:
PATH=…….;D:\Program Files\MySQL\MySQL Server 5.6\bin (Note: 1. You must add a semicolon under the English input after the original PATH; 2. It is an append, not an overwrite.)
Step 4: Modify the configuration file
After configuring the environment variables, do not start mysql first, you also need to modify the configuration file. The default configuration file of mysql-5.6.1X is in D:\Program Files\MySQL\MySQL Server 5.6\my-default.ini, you can create it yourself A my.ini file where the configuration is modified:
[mysqld] basedir=C:\Program Files\MySQL\MySQL Server 5.6(mysql所在目录) datadir=C:\Program Files\MySQL\MySQL Server 5.6\data (mysql所在目录\data)
mydefault.ini内容如下:
my.ini内容如下:
第五步:安装mysql
首先,以管理员身份运行cmd(必须以管理员身份运行,否则权限不够,会出错)
接着,进入D:\Program Files\MySQL Server 5.6\bin目录,
然后,执行命令mysqld –install
,若无错,则会提示安装成功。有错则先安装“微软常用运行库”,网上搜一下,下载安装后继续。
注:若之前安装过mysql,但由于某种原因未卸载干净,当再次安装mysql时,会提示此服务已存在。可用sc delete mysql命令,删除之前的版本,再执行mysqld –install命令。
第六步:启动mysql服务器
在cmd中 输入net start mysql
命令。
第七步:登录mysql
在cmd中,输入 mysql -u root -p
,第一次登录没有密码,直接回车,登陆成功。
退出mysql的命令是exit 。直接关闭cmd窗口是没有退出的,要输入exit才会退出。
设置密码:
进入mysql命令行:
1、set password for 'root'@'localhost' =password('你的密码');
2、mysql> use mysql;
Database changed
mysql> update user set password=password('654321') where user='root';
Query OK, 3 rows affected (0.00 sec)