后端的人员都会用到数据库,一大部分人喜欢用mysql,因为mysql是开源的,那么mysql怎么安装呢?如果不注意安装不成功,很有可能导致删除不干净再一次也很难安装成功,这篇文章小猿圈加加详细介绍一下,mysql的安装过程,大家一起来看看吧。
1、下载MySQL 8.0.16,地址:官网下载
2、解压到你自己的磁盘
3. 配置Path路径:系统属性 => 高级 => 高级 => 系统变量 => path后添加 (如:D:\Tools\mysql-8.0.16-winx64\bin)
4. 在mysql根目录下新建 my.ini,此文件是初始化信息(默认mysql根目录不存此文件):
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the # *** default location during install, and will be replaced if you # *** upgrade to a newer version of MySQL. [mysqld] # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. basedir = D:\Tools\mysql-8.0.16-winx64 datadir = D:\Tools\mysql-8.0.16-winx64\data port = 3306 # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
5. 系统管理员模式运行cmd 输入如下命令
C:\WINDOWS\system32>d: //进入d盘 D:\>cd "Tools\mysql-8.0.16-winx64\bin" //进入mysql bin文件下 D:\Tools\mysql-8.0.16-winx64\bin>mysqld --install //执行安装mysql服务进程 Service successfully installed. //提示服务安装成功 D:\Tools\mysql-8.0.16-winx64\bin>mysqld --initialize --console //根据配置文件初始化mysql,注意查看输出的日志中有临时密码, C_:qVsvG6Hxa 就是登录的临时密码 A temporary password is generated for root@localhost: C_:qVsvG6Hxa D:\Tools\mysql-8.0.16-winx64\bin>net start mysql //启动mysql服务 D:\Tools\mysql-8.0.16-winx64\bin>mysql -uroot -p //登录mysql Enter password: //这里输入上面的临时密码 mysql> alter user root@localhost identified by '123456'; //修改密码,123456是当前root账号登陆的密码 mysql> flush privileges; // 刷新系统表 应用上面修改的新密码
到处安装完成!
只要按着上面的步骤走,一般是不会导致mysql会安装失败的,一定要一步一步来,这样防止mysql安装不成功,后面会很麻烦的,这篇文章就到这了,希望看到这篇文章的朋友们能顺利安装成功,安装完毕之后,咱们就可以通过命令对数据库进行增、删、改、查了,下一篇文章小猿圈加加会详细写,可以先去小猿圈预习一下,咱们下篇见。