Ubuntu 16.04 中“root”用户的数据库访问被拒绝
在 Ubuntu 16.04 中使用 Web 服务器访问数据库时,您可能会遇到错误“SQLSTATE[HY000] [1698] 用户‘root’@‘localhost’的访问被拒绝”。尽管创建了具有所有权限的新用户,还是会出现此问题。
MySQL 5.7 中的根用户限制
此错误的根本原因在于 MySQL 5.7 中引入的更改,这限制了没有 sudo 权限的“root”用户的使用。在以前的版本中,用户可以使用“mysql -u root”命令以“root”身份访问 MySQL,而无需提升权限。然而,在 MySQL 5.7 中,这种方法不再可行。
解决方法
要解决此问题,您需要创建一个具有必要权限的新用户并使用从 PHP 应用程序或其他非命令行工具建立数据库连接时,请使用该用户而不是“root”。
PHP 代码
在您的 PHP 代码中,替换用户名和密码以及新创建用户的凭据:
<code class="php">protected $name = 'new_user'; protected $pass = 'new_password';</code>
从命令行进行根访问
虽然您不能直接使用“root”用户GUI 或非命令行应用程序,您仍然可以使用 sudo 以“root”身份从命令行访问 MySQL:
sudo mysql -u root
请记住,此方法会提升您的权限,仅应在必要时使用。出于安全原因,建议创建一个专用用户进行数据库管理并使用该用户而不是“root”。
以上是为什么我无法在 Ubuntu 16.04 中以'root”身份连接到 MySQL?的详细内容。更多信息请关注PHP中文网其他相关文章!

mysqlviewshavelimitations:1)他们不使用Supportallsqloperations,限制DatamanipulationThroughViewSwithJoinSorsubqueries.2)他们canimpactperformance,尤其是withcomplexcomplexclexeriesorlargedatasets.3)

porthusermanagementInmysqliscialforenhancingsEcurityAndsingsmenting效率databaseoperation.1)usecReateusertoAddusers,指定connectionsourcewith@'localhost'or@'%'。

mysqldoes notimposeahardlimitontriggers,butacticalfactorsdeterminetheireffactective:1)serverConfiguration impactactStriggerGermanagement; 2)复杂的TriggerSincreaseSySystemsystem load; 3)largertablesslowtriggerperfermance; 4)highConconcConcrencerCancancancancanceTigrignecentign; 5); 5)

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

通过PHP网页界面添加MySQL用户可以使用MySQLi扩展。步骤如下:1.连接MySQL数据库,使用MySQLi扩展。2.创建用户,使用CREATEUSER语句,并使用PASSWORD()函数加密密码。3.防止SQL注入,使用mysqli_real_escape_string()函数处理用户输入。4.为新用户分配权限,使用GRANT语句。

mysql'sblobissuitableForStoringBinaryDataWithInareLationalDatabase,而alenosqloptionslikemongodb,redis和calablesolutionsoluntionsoluntionsoluntionsolundortionsolunsolunsstructureddata.blobobobsimplobissimplobisslowderperformandperformanceperformancewithlararengelitiate;

toaddauserinmysql,使用:createUser'username'@'host'Indessify'password'; there'showtodoitsecurely:1)choosethehostcarecarefullytocon trolaccess.2)setResourcelimitswithoptionslikemax_queries_per_hour.3)usestrong,iniquepasswords.4)Enforcessl/tlsconnectionswith

toAvoidCommonMistakeswithStringDatatatPesInMysQl,CloseStringTypenuances,chosethirtightType,andManageEngencodingAndCollationsEttingsefectery.1)usecharforfixed lengengters lengengtings,varchar forbariaible lengength,varchariable length,andtext/blobforlabforlargerdata.2 seterters seterters seterters seterters


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

ZendStudio 13.5.1 Mac
功能强大的PHP集成开发环境

禅工作室 13.0.1
功能强大的PHP集成开发环境

记事本++7.3.1
好用且免费的代码编辑器