MySql is installed under Windows and Linux

First, install mysql under windows

1. Download mysql package: https: //dev.mysql.com/downloads/mysql/

 

2. Extract to a specific place you can (as is the installed files, so I use free installation)

As my habit: D: \ software is the path used for software installation.

The mysql-8.0.17-winx64 extract to herein (free installation):

 

3. Configure environment variables (My Computer, right property, Advanced System Settings, Advanced, Environment Variables)

New environment variables:

Variable name: MYSQL_HOME

Variable value: D: \ software \ mysql-8.0.17-winx64 \ bin 

 

 

4.cmd free password to log into mysql once, remember not to quit, then set a new password

Run as administrator cmd

Enter D: \ software \ mysql-8.0.17-winx64> lower (cmd not cut disc, see question b):

Execute the command: mysqld --initialize-insecure --user = mysql (in D: \ software \ mysql-8.0.17-winx64 \ bin directory to generate data directory, do not know right, ignore this sentence)

After the play command execution, execution: mysqld -install (represented in the current installation directory bin)

Execution: net start MySQL (to start the service)

Enter D: \ software \ mysql-8.0.17-winx64 \ bin> mysql -u root -p (prompt for a password, hit enter, the first time the password is blank)

Query User Password command: mysql> select host, user, authentication_string from mysql.user; (can know the root password is empty, we can now withdraw after setting a password, be sure to set, or not come back);

执行:mysql>alter user 'root'@'localhost' identified by '123456'; 
flush privileges;

那么你的密码就设置为123456了

可以使用 mysql>quit (退出)

 

5.尝试使用第三方的工具(Navicat)连接。(如果失败,请查看问题a)

 

 

二、Linux 下安装mysql(命令式,简单的安装方式) 

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm yum update yum install mysql-server

权限设置:

chown mysql:mysql -R /var/lib/mysql

初始化 MySQL:

mysqld --initialize

启动 MySQL:

systemctl start mysqld

查看 MySQL 运行状态:

systemctl status mysqld

查看版本(如下,则说明mysql安装成功):
[root@host]# mysqladmin --version

linux上该命令将输出以下结果,该结果基于你的系统信息:

mysqladmin  Ver 8.23 Distrib 5.0.9-0, for redhat-linux-gnu on i386

如果是服务器上的,比如阿里,则在阿里控制台开启3306端口,方可远程连接mysql

 

 

 

 

-------------------------------a.问题:(第三方工具链接不上)-----------------------------------------

1.cmd 进去到mysql目录的bin 登录后,执行以下语句即可。

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密规则 
 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用户的密码 

FLUSH PRIVILEGES; #刷新权限 

再重置下密码:alter user 'root'@'localhost' identified by '123qwe';   #(123qwe 是你的新密码,头2句语句,用‘password’即可)

退出后,使用第三方软件即可连接;

 

 

 

-------------------------------b.问题:(cmd 命令使用)-----------------------------------------

关键词:CD (进入),C: (切换到C盘) , D:(切换到D盘)  , Ctrl+Ins (等同在cmd的鼠标右键,功能是粘贴)

要进入到 D:\software\mysql-8.0.17-winx64 这里为例:

搜索cmd 右键管理员运行

1.使用  D:  回车

 2.

 

 输入 cd  右键,即可进入。

 进入bin  输入输入: cd bin

 

----------------------------------C.问题:(如果有旧mysql 比如C盘也有一个旧的mysql 卸载它的教程如下)------------------------

彻底卸载mysql: (参考:https://blog.csdn.net/py_123456/article/details/79694786)

  1)删除程序。进入控制面板->在程序和功能选项卡中找到MySQL,右键卸载。

  2)删除安装文件夹下的所有内容。找到MySQL的安装路径,然后删除路径下所有文件。

  3)删除注册表。Windows+R打开运行命令框,输入regedit回车,删除以下3个地方的注册文件:

HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\Application\MySQL 目录删除 

    HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Eventlog\Application\MySQL 目录删除 

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog\Application\MySQL 目录删除

  4)最重要的一点(我就是由于没有删除此文件而导致出错的):进入C盘,选中查看->勾选“隐藏的项目”,然后下面就出来隐藏目录(ProgramData)了,进入其中,删除MySQL文件夹。

 

到此,你已卸载干净了。最后:你就重新安装mysql即可了。

 

----------------------------------------------------------------------------------------------------------------------------------

 

Guess you like

Origin www.cnblogs.com/Bruke/p/11615320.html