重装升级mysql出现的启动服务的问题

原本的版本是5.5的,有点老了,有些新的功能不支持,就决定升级一下,升级到5.7。

网上下载的压缩包是5.7.20的版本。

直接在5.5的版本上升级太难了。。索性就把5.5卸载之后直接装5.7的。要备份好数据!!!

但是mysql也很不好卸载。

再记录一下步骤:

1. 命令删除服务 sc delete mysql

2. 删除文件所在位置的全部文件夹,我的是在C盘

3. 删除注册表。这三个目录下的 services-->eventlog-->system-->mysql文件

4. 重启

安装5.7

1. 把压缩包解压。我的解压在C盘

2. 新建一个my.ini文件,并配置该文件

# CLIENT SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by MySQL client applications.
# Note that only client applications shipped by MySQL are guaranteed
# to read this section. If you want your own MySQL client program to
# honor these values, you need to specify it as an option during the
# MySQL client library initialization.
#
[client]

port=3306

[mysql]

default-character-set=utf8


# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
[mysqld]

# The TCP/IP Port the MySQL Server will listen on
port=3306


#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/mysql-5.7.20-winx64"

#Path to the database root
datadir="C:/Program Files/mysql-5.7.20-winx64/date"

# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8

# The default storage engine that will be used when create new tables when
default-storage-engine=INNODB

# Set the SQL mode to strict
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"

# The maximum amount of concurrent sessions the MySQL server will
# allow. One of these connections will be reserved for a user with
# SUPER privileges to allow the administrator to login even if the
# connection limit has been reached.
max_connections=100

# Query cache is used to cache SELECT results and later return them
# without actual executing the same query once again. Having the query
# cache enabled may result in significant speed improvements, if your
# have a lot of identical queries and rarely changing tables. See the
# "Qcache_lowmem_prunes" status variable to check if the current value
# is high enough for your load.
# Note: In case your tables change very often or if your queries are
# textually different every time, the query cache may result in a
# slowdown instead of a performance improvement.
query_cache_size=0

# The number of open tables for all threads. Increasing this value
# increases the number of file descriptors that mysqld requires.
# Therefore you have to make sure to set the amount of open files
# allowed to at least 4096 in the variable "open-files-limit" in
# section [mysqld_safe]
table_open_cache=256

# Maximum size for internal (in-memory) temporary tables. If a table
# grows larger than this value, it is automatically converted to disk
# based table This limitation is for a single table. There can be many
# of them.
tmp_table_size=35M


# How many threads we should keep in a cache for reuse. When a client
# disconnects, the client's threads are put in the cache if there aren't
# more than thread_cache_size threads from before.  This greatly reduces
# the amount of thread creations needed if you have a lot of new
# connections. (Normally this doesn't give a notable performance
# improvement if you have a good thread implementation.)
thread_cache_size=8

#*** MyISAM Specific options

# The maximum size of the temporary file MySQL is allowed to use while
# recreating the index (during REPAIR, ALTER TABLE or LOAD DATA INFILE.
# If the file-size would be bigger than this, the index will be created
# through the key cache (which is slower).
myisam_max_sort_file_size=100G

# If the temporary file used for fast index creation would be bigger
# than using the key cache by the amount specified here, then prefer the
# key cache method.  This is mainly used to force long character keys in
# large tables to use the slower key cache method to create the index.
myisam_sort_buffer_size=69M

# Size of the Key Buffer, used to cache index blocks for MyISAM tables.
# Do not set it larger than 30% of your available memory, as some memory
# is also required by the OS to cache rows. Even if you're not using
# MyISAM tables, you should still set it to 8-64M as it will also be
# used for internal temporary disk tables.
key_buffer_size=55M

# Size of the buffer used for doing full table scans of MyISAM tables.
# Allocated per thread, if a full scan is needed.
read_buffer_size=64K
read_rnd_buffer_size=256K

# This buffer is allocated when MySQL needs to rebuild the index in
# REPAIR, OPTIMZE, ALTER table statements as well as in LOAD DATA INFILE
# into an empty table. It is allocated per thread so be careful with
# large settings.
sort_buffer_size=256K

3. 终端输入命令,移除mysql

mysqld -remove

4. 终端输入命令,安装mysql

mysqld -install

5. 终端输入命令,初始化mysql。初始化成功会在my.ini所在的文件目录下自动生成date文件夹,此时文件夹内什么都没有。

mysqld --initialize --console

6. 启动mysql服务

net start mysql

此时大部分会出现服务未启动,服务自动停止balabala...

此时再打开date文件夹内,会有3个文件,第一个err文件,另外两个是log文件不用管,把err文件打开,找前面是[error]的,逐项修改。

我遇到的是unknown variable 'table-cache=256' 。把table_cache 修改为table_open_cache即可。

但是修改后不管怎么重启和更新都还是出现服务未启动,错误一直是这个,仍然是未修改前的数据。。

最后实在没办法,把解压的整个文件夹直接删除了,重新解压安装,新建my.ini文件的时候直接把该项修改。

然后把该文件复制一份到C:\Windows的目录下。

再次操作以上步骤。。

查看date文件夹内会出现新的错误:大概意思是让先执行mysql_upgrade更新一下。

此时只需要把bin目录的这个程序执行一下就行了。

然后再次操作启动服务

又出现了如下的错误:

把date文件夹内的所有错误文件、log文件都删除后。错误没有了。

再启动服务,就启动成功了!

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

服务启动后,没有设置帐号密码。。没办法登陆。出现如下错误:

access denied for user 'root@localhost'

于是重新设置密码。。以下copy别人的,原文链接在下面。。。

1、开始 → 搜索栏里面输入cmd → 右键cmd.exe选择以管理员的身份运行(亦可以在C:\Windows\System32目录下找到这个cmd.exe,右键,以管理员身份运行)

2、输入net stop mysql停止MySQL服务

3、输入命令行来到mysql的bin目录下,输入下列粗体命令(文件位置根据自己实际情况更换)

C:\MySQL\bin>mysqld  --defaults-file="C:\MySQL\my.ini" --console --skip-grant-tables

等一下,显示出以下结果说明MySQL启动:

  170215 22:26:09 [Warning] The syntax '--log' is deprecated and will be removed  inMySQL 7.0. Please use '--general_log'/'--general_log_file' instead.
  170215 22:26:09 [Warning] The syntax '--log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '--slow_query_log'/'--  slow_query_log_file' instead.
  170215 22:26:09 [Warning] The syntax '--log' is deprecated and will be removed in MySQL 7.0. Please use '--general_log'/'--general_log_file' instead.
  170215 22:26:09 [Warning] The syntax '--log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '--slow_query_log'/'--slow_query_log_file' instead.
  170215 22:26:09 [ERROR] The update log is no longer supported by MySQL in version 5.0 and above. It is replaced by the binary log. Now starting MySQL with --log-bin='' instead.
  170215 22:26:09  InnoDB: Started; log sequence number 0 324221
  170215 22:26:09 [Note] mysqld: ready for connections.Version: '5.1.33-community-log'  socket: ''  port: 3306  MySQL Community Server (GPL)

4、再以管理员的身份打开一个cmd.exe,输入命令行来到mysql的bin目录下,输入:mysql -uroot mysql

5、进入mysql之后,输入命令行修改密码:

mysql>update user set authentication_string=password('123456') where user='root';

6、刷新权限:mysql>flush privileges;

7、退出mysql:mysql> quit;

8、关闭MySQL:D:\MySQL\bin>mysqladmin shutdown(出现错误,则:mysqladmin -uroot -p shutdown 然后输入新密码)

9、至此修改密码完成,可以输入命令行:net start mysql 启动MySQL服务,mysql -uroot -p ,输入密码就可以进入mysql了。

在第8步,出现错误后,重新登陆出现

your password has expired错误

我差点重新设置遍,事实上是已经开始重新设置,但是刚开始就出现错误了,就没再重新设置

退出命令终端,重新打开,试着登陆了一下,登陆成功!

 

感谢:https://www.cnblogs.com/da19951208/p/6403783.html?utm_source=itdadao&utm_medium=referral

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值