mysq安装以及修改密码

安装版MySQL是不能一键安装的,下载下来是压缩包,解压后只要进行相关配置就可以正常使用;

文章主要是记录一下,以防自己忘记;

 

1、首先在mysql官网--http://dev.mysql.com/downloads/mysql/  下载mysql;

 

 

2、下载后解压到对应路径

我是放在 D:\mysql-5.7.14-winx64\ 里面,解压完后改名,可以自己进行重命名;

 

3、配置环境变量

找到--高级系统变量--环境变量--系统变量

新建环境变量:变量名 MYSQL_HOME,变量值 D:\mysql-5.7.14-winx64;

找到path--编辑--在最后面加上 ;%MYSQL_HOME%/bin ;

(这是我的mysql的bin目录,请设置自己电脑上相应的目录); 然后确定保存;

 

4,检查mysql目录下有没有data目录;

如果有data目录,忽略本点;

如果没有,win+r 打开运行,输入cmd进入命令窗;

进入mysql所在盘符。比如:d:

然后cd到mysql的bin目录,执行如下语句: mysqld --initialize-insecure --user=mysql ;data目录就生成成功了

 

 

5,配置mysql目录内的  my-default.ini (没有就新建个)

在[mysqld]下,修改以下三个参数,默认是用#注释的,去掉#;

basedir = D:\mysql-5.7.14-winx64
datadir = D:\mysql-5.7.14-winx64\data
port = 3306

注意:basedir   和datadir是我本地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 = E:\mysql-5.7.16-winx64
datadir = E:\mysql-5.7.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
ql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
loose-default-character-set = utf8
character_set_server = utf8
[client]
loose-default-character-set = utf8
port = 3306
user=root
password=admin

6,安装;

用管理员权限打开系统命令窗口,

输入:mysqld --install

提示service successfully installed安装成功;

 

7,停止和启动mysql

启动:net  start  mysql

停止:net  stop  mysql

 

 

8,进入mysql以及修改密码

在mysql目录下,编辑 my-default.ini

在[mysqld]下添加一行     skip-grant-tables     暂时取消密码;

直接输入:SET PASSWORD = PASSWORD('你的新密码');

重启mysql,用 mysql -uroot -p123456。

########

其他更改密码方法

1,重启mysql,;

2,输入 mysql -uroot -p   按回车,如果提示输入密码,直接回车即可;

, 3,登陆成功后,输入   update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';    将密码先修改为123456;

4,输入 flush privileges;刷新保存;

5,删除  my-default.ini 中刚刚添加的   skip-grant-tables   保存;

6,exit;或quit; 退出mysql;

7,重启mysql;

8,使用新密码登陆:  mysql -uroot -p123456   回车即可登陆成功;

9,ok了! 

mysql 5.7.16 忘记root 密码 如何修改root密码

今天在电脑上安装  mysql5.7.16 (压缩包)时,在初始化data文件夹之后,没有记住密码,DOS框没有显示,没办法,为了学习一下怎么修改密码,在网上找了好多方法去解决,最终还是解决了,下面来看一下这种方法的具体操作:

 

    1. 关闭正在运行的MySQL服务。 

    2. 打开DOS窗口,转到mysql\bin目录

    3. 输入mysqld --skip-grant-tables 回车
            --skip-grant-tables 的意思是启动MySQL服务的时候跳过权限表认证。 

    4. 再开一个DOS窗口(因为刚才那个DOS窗口已经不能动了),转到mysql\bin目录。 

    5. 输入mysql回车,如果成功,将出现MySQL提示符 >。 

    6. 连接权限数据库: use mysql;  (别忘了最后加分号) 。

    7. 改密码:update user set password=password("123") where user="root"; (别忘了最后加分号) 。 

    如果修改密码出现 
    **mysql修改密码错误 ERROR 1054 (42S22)**

    则使用 mysql>update mysql.user set authentication_string=password('123456') where user='root' and Host ='localhost';
 
  通过上面的修改,root密码已经修改成功了,此时你如果去启动mysql服务时,服务  应该会启动不了,我的办法是从新启动了电脑,从新启动服务,此时  mysql服务可以正常启
动,  此时 通过 navicat 可以以新的密码连接,或者通过 mysql命令行来进入数据库。

 

mysql-5.7.10-winx64 MySQL服务无法启动,服务没有报告任何错误的解决办法
宛珩 发表于10个月前
 
 
 
 
 
 
 
原mysql-5.7.10-winx64 MySQL服务无法启动,服务没有报告任何错误的解决办法
 
  • 发表于 10个月前  
  • 阅读 3555  
  • 收藏 4  
  • 点赞 3  
  • 评论 1
总结报错原因: 
在my.init文件下新增data目录(datadir = F:\mysqldata ) 

最新解压版本的mysql 解压安装的时候报错 
D:\mysql\mysql-5.7.10-winx64\bin>net start mysql 
MySQL 服务正在启动 .... 
MySQL 服务无法启动。 

服务没有报告任何错误。 

请键入 NET HELPMSG 3534 以获得更多的帮助。 

  
  
mysql下面是没有data文件夹的,此文件夹不需要自己建 
  
D:\mysql\mysql-5.7.10-winx64\bin> mysqld --console 
2015-12-21T07:25:01.465815Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 
2015-12-21T07:25:01.465815Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They willbe merged with strict mode in a future release. 
2015-12-21T07:25:01.465815Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set. 
2015-12-21T07:25:01.465815Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path. 
2015-12-21T07:25:01.467815Z 0 [Note] mysqld (mysqld 5.7.10-log) starting as process 3708 ... 
2015-12-21T07:25:01.491816Z 0 [Warning] No argument was provided to --log-bin, and --log-bin-index was not used; so replication may break when this MySQL server acts as a master and has his hostname changed!! Please use '--log-bin=PC201305252052-bin' to avoid this problem. 
2015-12-21T07:25:01.527818Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions 
2015-12-21T07:25:01.528818Z 0 [Note] InnoDB: Uses event mutexes 
2015-12-21T07:25:01.531819Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier 
2015-12-21T07:25:01.535819Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 
2015-12-21T07:25:01.540819Z 0 [Note] InnoDB: Number of pools: 1 
2015-12-21T07:25:01.544819Z 0 [Note] InnoDB: Not using CPU crc32 instructions 
2015-12-21T07:25:01.654826Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 
2015-12-21T07:25:01.705829Z 0 [Note] InnoDB: Completed initialization of buffer pool 
2015-12-21T07:25:01.834836Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 
2015-12-21T07:25:01.991845Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 
2015-12-21T07:25:01.994845Z 0 [Note] InnoDB: Setting file '.\ibtmp1' size to 12MB. Physically writing the file full; Please wait ... 
2015-12-21T07:25:02.264861Z 0 [Note] InnoDB: File '.\ibtmp1' size is now 12 MB. 
2015-12-21T07:25:02.275861Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 
96 redo rollback segment(s) are active. 
2015-12-21T07:25:02.276861Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 
2015-12-21T07:25:02.284862Z 0 [Note] InnoDB: Waiting for purge to start 
2015-12-21T07:25:02.335865Z 0 [Note] InnoDB: 5.7.10 started; log sequence number 1209980 
2015-12-21T07:25:02.338865Z 0 [Note] Plugin 'FEDERATED' is disabled. 
2015-12-21T07:25:02.339865Z 0 [Note] InnoDB: Loading buffer pool(s) from F:\mysqldata\ib_buffer_pool 
2015-12-21T07:25:02.339865Z 0 [Note] InnoDB: not started mysqld: Table 'mysql.plugin' doesn't exist 
2015-12-21T07:25:02.348865Z 0 [Note] InnoDB: Buffer pool(s) load completed at 151221 15:25:02 
2015-12-21T07:25:02.351865Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 
2015-12-21T07:25:02.396868Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 
2015-12-21T07:25:02.401868Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key 
2015-12-21T07:25:02.402868Z 0 [Note] Server hostname (bind-address): '*'; port:3306 
2015-12-21T07:25:02.415869Z 0 [Note] IPv6 is available. 
2015-12-21T07:25:02.416869Z 0 [Note]   - '::' resolves to '::'; 
2015-12-21T07:25:02.419869Z 0 [Note] Server socket created on IP: '::'. 
2015-12-21T07:25:02.430870Z 0 [Warning] Failed to open optimizer cost constant tables 


2015-12-21T07:25:02.436870Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist 
2015-12-21T07:25:02.440871Z 0 [ERROR] Aborting 


2015-12-21T07:25:02.441871Z 0 [Note] Binlog end 
2015-12-21T07:25:02.457872Z 0 [Note] Shutting down plugin 'ngram' 
2015-12-21T07:25:02.457872Z 0 [Note] Shutting down plugin 'partition' 
2015-12-21T07:25:02.460872Z 0 [Note] Shutting down plugin 'BLACKHOLE' 
2015-12-21T07:25:02.463872Z 0 [Note] Shutting down plugin 'ARCHIVE' 
2015-12-21T07:25:02.468872Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' 
2015-12-21T07:25:02.468872Z 0 [Note] Shutting down plugin 'MRG_MYISAM' 
2015-12-21T07:25:02.475873Z 0 [Note] Shutting down plugin 'MyISAM' 
2015-12-21T07:25:02.476873Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL' 
2015-12-21T07:25:02.480873Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES' 


2015-12-21T07:25:02.482873Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES' 
2015-12-21T07:25:02.493874Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS' 
2015-12-21T07:25:02.495874Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN' 
2015-12-21T07:25:02.498874Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS' 
2015-12-21T07:25:02.503874Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS' 
2015-12-21T07:25:02.509875Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES' 
2015-12-21T07:25:02.513875Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS' 
2015-12-21T07:25:02.518875Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES' 
2015-12-21T07:25:02.521875Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE' 
2015-12-21T07:25:02.524875Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE' 
2015-12-21T07:25:02.528876Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG' 
2015-12-21T07:25:02.531876Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED' 
2015-12-21T07:25:02.537876Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED' 
2015-12-21T07:25:02.539876Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD' 
2015-12-21T07:25:02.542876Z 0 [Note] Shutting down plugin 'INNODB_METRICS' 
2015-12-21T07:25:02.545877Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO' 
2015-12-21T07:25:02.553877Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS' 
2015-12-21T07:25:02.555877Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU' 
2015-12-21T07:25:02.558877Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE' 
2015-12-21T07:25:02.561878Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET' 
2015-12-21T07:25:02.563878Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX' 


2015-12-21T07:25:02.566878Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET' 
2015-12-21T07:25:02.572878Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM' 
2015-12-21T07:25:02.574878Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET' 
2015-12-21T07:25:02.577878Z 0 [Note] Shutting down plugin 'INNODB_CMP' 
2015-12-21T07:25:02.580879Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS' 
2015-12-21T07:25:02.582879Z 0 [Note] Shutting down plugin 'INNODB_LOCKS' 
2015-12-21T07:25:02.584879Z 0 [Note] Shutting down plugin 'INNODB_TRX' 
2015-12-21T07:25:02.586879Z 0 [Note] Shutting down plugin 'InnoDB' 
2015-12-21T07:25:02.587879Z 0 [Note] InnoDB: FTS optimize thread exiting. 
2015-12-21T07:25:02.589879Z 0 [Note] InnoDB: Starting shutdown... 
2015-12-21T07:25:02.690885Z 0 [Note] InnoDB: Dumping buffer pool(s) to F:\mysqldata\ib_buffer_pool 
2015-12-21T07:25:02.698885Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 151221 15:25:02 
2015-12-21T07:25:03.850951Z 0 [Note] InnoDB: Shutdown completed; log sequence number 1209999 
2015-12-21T07:25:03.853951Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 
2015-12-21T07:25:03.863952Z 0 [Note] Shutting down plugin 'MEMORY' 
2015-12-21T07:25:03.866952Z 0 [Note] Shutting down plugin 'CSV' 
2015-12-21T07:25:03.876953Z 0 [Note] Shutting down plugin 'sha256_password' 
2015-12-21T07:25:03.879953Z 0 [Note] Shutting down plugin 'mysql_native_password' 
2015-12-21T07:25:03.882953Z 0 [Note] Shutting down plugin 'binlog' 
2015-12-21T07:25:03.892954Z 0 [Note] mysqld: Shutdown complete 

  
  
D:\mysql\mysql-5.7.10-winx64\bin> mysqld --initialize 
2015-12-21T07:28:50.310904Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 
2015-12-21T07:28:50.311904Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They willbe merged with strict mode in a future release. 
2015-12-21T07:28:50.311904Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set. 
2015-12-21T07:28:50.318904Z 0  [ERROR] --initialize specified but the data directory has files in it. Aborting . 
2015-12-21T07:28:50.324905Z 0  [ERROR] Aborting 

  
  
上面的错误是自己建了data文件夹之后 用 mysqld  --initialize报错。 
  
删除之前建的data文件夹,然后注释my.init文件下的datadir,由mysql自己创建即可。 
D:\mysql-5.7.10-winx64\bin>mysqld  --initialize 
D:\mysql-5.7.10-winx64\bin>net start mysql 
MySQL 服务正在启动 . 
MySQL 服务已经启动成功。

MySQL 5.6安装成功后如何设置密码?

按照安装教程安装成功以后,是默认没有密码的。

命令行输入:

mysql -u root -p

即可成功登录,提示 welcome to the  mysql monitor!的字样即表示登录成功。

关闭当前命令行,重启cmd.exe

输入mysqladmin -u root -p password

回车,

出现“Enter password:”,直接回车,未设置密码时默认没有密码,

接着出现“New password:”输入新的密码,回车即可,

接着出现“Confirm new password:”确认密码,回车即可。

修改完密码以后,下次重新登录是,

键入mysql -u root -p即可,接着输入设置后的密码即可登录。

转载于:https://www.cnblogs.com/liwentao/p/6185130.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值