mysql初始化登录报错解决-1

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用系列 2核4GB
简介:

场景还原:

初始化

#/usr/local/webserver/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/webserver/mysql/ --datadir=/home/mysqldata

Installing MySQL system tables...
150205 11:48:00 [Note] Flashcache bypass: disabled
150205 11:48:00 [Note] Flashcache setup error is : ioctl failed

OK
Filling help tables...
150205 11:48:00 [Note] Flashcache bypass: disabled
150205 11:48:00 [Note] Flashcache setup error is : ioctl failed

OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/webserver/mysql//bin/mysqladmin -u root password 'new-password'
/usr/local/webserver/mysql//bin/mysqladmin -u root -h kooxoo17.ktep3.kuxun.cn password 'new-password'

Alternatively you can run:
/usr/local/webserver/mysql//bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/webserver/mysql/ ; /usr/local/webserver/mysql//bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/webserver/mysql//mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/webserver/mysql//scripts/mysqlbug script!

Percona recommends that all production deployments be protected with a support
contract (http://www.percona.com/mysql-suppport/) to ensure the highest uptime,
be eligible for hot fixes, and boost your team's productivity.

启动

/usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --basedir=/usr/local/webserver/mysql/ --datadir=/home/mysqldata  &

正常启动。ps -ef | grep mysql 也有相应的进程存在

尝试如下4种方式登录:

# /usr/local/webserver/mysql/bin/mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

# /usr/local/webserver/mysql/bin/mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

# /usr/local/webserver/mysql/bin/mysql -S /tmp/mysql.sock
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

]# /usr/local/webserver/mysql/bin/mysql -u root -S /tmp/mysql.sock
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

而my.cnf中指定的socket就是/tmp/mysql.sock 这个路径

或者如下这种报错:

# /usr/local/webserver/mysql/bin/mysql

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

# /usr/local/webserver/mysql/bin/mysql -u root

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

# /usr/local/webserver/mysql/bin/mysql -S /tmp/mysql.sock

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

#/usr/local/webserver/mysql/bin/mysql -u root -S /tmp/mysql.sock

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


原因是:进行了多次初始化,但是每次初始化的时候没有删除datadir下生成的文件导致的!

切记,每次初始化操作都要删除datadir下生产的文件哦!




      本文转自Tenderrain 51CTO博客,原文链接:http://blog.51cto.com/tenderrain/1612028,如需转载请自行联系原作者





相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
打赏
0
0
0
0
348
分享
相关文章
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
【YashanDB知识库】MySQL和YashanDB 隐式转换不一致引起的报错
本文分析了在YashanDB中执行特定SQL语句时出现的类型转换错误问题,并对比了YashanDB、Oracle和MySQL 5.7的行为差异。问题源于隐式类型转换,当数值字段与非法数字字符串(如'1,2')进行比较时,YashanDB和Oracle会报错,而MySQL 5.7虽不报错但会引发警告。通过调整SQL语句,避免数值与字符串直接比较,可有效解决问题。文章还详细解析了不同值表现不一致的原因,涉及执行计划和过滤条件的实际运行细节。
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
【YashanDB知识库】YMP从mysql迁移到崖山,报错:服务器错误
【YashanDB 知识库】MySQL 和 YashanDB 隐式转换不一致引起的报错
【YashanDB 知识库】MySQL 和 YashanDB 隐式转换不一致引起的报错
升级到MySQL 8.4,MySQL启动报错:io_setup() failed with EAGAIN
当MySQL 8.4启动时报错“io_setup() failed with EAGAIN”时,通常是由于系统AIO资源不足所致。通过增加AIO上下文数量、调整MySQL配置、优化系统资源或升级内核版本,可以有效解决这一问题。上述解决方案详细且实用,能够帮助管理员快速定位并处理此类问题,确保数据库系统的正常运行。
186 9
2024Mysql And Redis基础与进阶操作系列(6)作者——LJS[含MySQL 多表之一对一/多;多对多;多表联合查询等详解步骤及常见报错问题所对应的解决方法]
MySQL 多表之一对一/多;多对多;多表联合之交叉连接;内连接;左、右、外、满、连接;子查询及关键字;自连接查询等详解步骤及常见报错问题所对应的解决方法
【YashanDB知识库】原生mysql驱动配置连接崖山数据库
【YashanDB知识库】原生mysql驱动配置连接崖山数据库
【YashanDB知识库】原生mysql驱动配置连接崖山数据库
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等