1

So I am stuck with this error when trying to connect my node.js application with MySQL. It won't let me connect to MySQL from localhost, not a single command is working.

enter image description here

The MySql workbench also says the same

enter image description here

I can't use any database commands since it's not letting me access mysql. Gone through almost all possible solutions on the internet none of them worked. Please help me out here even an explanation for this would help if not the solution.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Tushar saxena
  • 317
  • 4
  • 15

1 Answers1

1

In order to access you must do the following steps :

1. Run the terminate with user permission.

2. Access the path where you have mysql installed.

3. Put the following sentence.

mysql.exe -u root -ppasw

-u : It is the user.

-p : the password but next to the p without space.

If it does not work try this in windows cmd

To restore to a single concrete database.

mysqlbinlog -database='yourFile.00004'

Explanation : The Binary log.

  • It has replaced the old update file.

  • Its mission is to update the DBs during a recovery operation.

  • Replication masters are used as a reminder of the statements to be sent to the slave servers.

  • If the name is not specified, the host is chosen.

  • Performance drop of 1%.

  • Active bins must not be opened during execution.

  • If you put extension to the file, it is ignored.

  • A new BIN_LOG file is created when :

    • The server is restarted

    • A Flush binary Logs is made

    • The size specified in MAX_BINLOG_SIZE is exceeded.

  • The files that are generated have an extension that are sequential numbers and represent the order (index) of their creation controlled by the name host_name.index.

  • To activate and decomment the log-bin my.ini directive. If log-bin=file is used, that name will be used to name the sequence of files.

  • To delete index files.

    • purge binary before date-time (in this format "yyyy-mm-dd hh:mm:ss" or now() or interval....)

    • purge binary logs to filename; deletes up to this file (this one not included)

    • reset master -> deletes all files

  • To disable the binary log, the session variable is used.

    • SQL_LOG_BIN : Up to version 5.6 this one is

    • EXECUTE DB : binlog-do-db=BD

    • DOES NOT RUN DB : binlog-ignore-db=BD

  • The commands are the continuation of the binary log.

    • create database

    • alter database

    • drop database

  • To see the content of a binary file (must not be open).

mysqlbinlog "file with its path".
  • To restore several binary files must be done in one step.
mysqlbinlog file1 file2 file3 file3 | mysql -u root -ppassword
  • To restore.

    • Overwrite the file >

    • Adds in the content respecting the content >>

  • To restore to a single concrete database.

mysqlbinlog -database='filenamebinlog.00004'

If the above does not work, do this first

Another option

ERROR 1130 (HY000): Host 'localhost' is not allowed to connect to this MySQL server

Cause : mysql only has one root user, select MD5 after changing root password, then submit, reboot. Login appears "The host 'localhost' is not allowed to connect to this MySQL server..." Try the user table in another mysql library, overwrite, no, it is estimated that the version is different Resolve : Edit my.ini

Add a sentence to [mysqld]: skip-grant-tables

For example :

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables

The purpose is :

Bypass MySQL access control, anyone can log in to the MySQL database as an administrator in the console.

It should be noted that after changing the password, the MySQL server must be stopped and restarted to take effect.

Restart the mysql service!

Javier G.Raya
  • 230
  • 1
  • 3
  • 15
  • Thanks for posting this but unfortunately I am not able to access the mysql console at all. So this doesn't work. – Tushar saxena Mar 25 '22 at 11:55
  • but this is executed in the windows console, you do not need to enter the mysql console. – Javier G.Raya Mar 25 '22 at 11:59
  • Thank You @Javier G.Raya Your Answer worked well but since it's my work laptop I don't have the admin rights to start and stop MYSQL service. So I got stuck at that part. But I have raised a ticket for that it will get resolved. – Tushar saxena Mar 26 '22 at 12:55
  • you are welcome friend but if what you want is to restart the service with restarting the pc is enough for you – Javier G.Raya Mar 26 '22 at 14:06
  • Yea I did restarted the PC but the service is stopped its not restarting. – Tushar saxena Mar 27 '22 at 05:20
  • is that you need those permissions, talk to your administrator and tell them so that they can solve it or give you permissions. – Javier G.Raya Mar 27 '22 at 11:06