First of all I want to say I'm completely new to working with client/server architecture, beginner at using the command line, and have never fixed a program before. I downloaded MySql 5.6 for Windows 7 64 bit along with the MySql workbench.
So everything was working fine at first with logging in, databases working, sql queries, etc. What I wanted to do next was use php to access my database from a webpage. So I Installed Wampserver (which includes Apache, phpmyadmin, and I guess an Api for using mysql with php?) and afterwards I was not able to get into my server at all.
But, it's possible it's not because of installing Wampserver, because I did not check to see if it worked right after the install. What I did was, after I installed Wampserver, I changed my root password from Mysqlworkbench in order to have a password I could use. So, it must be that I can't connect to the server because (a) I changed the root login password from the workbench, or (b) I installed Wampserver. I have been messing with this for several hours trying different things, and I think the problem is probably with the files. From what I understand, if you want to log in to the server, it first authenticates your info by comparing it with another file? I think I probably have a problem with the my.ini file that I've seen mentioned.
This is usually what happens when I try to connect
owner>mysql -u root -p
Enter password: ********
Error 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)
So I was googling around but nothing I tried quite worked. So I went on Youtube, and there I found my answer. I will post the link here Youtube password video since it's easier than just explaining, though I will give a short summary. It was done with command line and making a .txt file named "mysql-init.txt". So I had to make a .txt file that contained a command to use mysql and update the mysql.user table, and update the password, then flush privileges. Then had to turn the mysql server service off. After that, I moved the "my.ini" file into the folder of the mysql server ("MySQL Server 5.6" for me). Then ,using the command prompt, went into the mysql server directory. And then I did this:
C:\Program Files\MySQL\MySQL Server 5.6>bin\mysqld.exe --defaults-file="my.ini" --init-file="C:\\Users\\Johnny\\Desktop\\mysql-init.txt" --console
After that, I just restarted the mysql server service, and the new password worked.
I'm using windows 7, it's probably different for other operating systems. There are a few things to note about the video though. He's using a different version of Mysql, so the name of the service for his mysql server is just mysql, but for me with mysql 5.6 installed, the name of the service is mysql56. Also, in the video, he has "my.ini" in the directory of his server, but for me, it was not there. After reading the comments, the "my.ini" file was in a hidden folder, so I unhid the folders (very easy) and found the "my.ini" and placed it in the "MySQL Server 5.6" folder. Also, in the video he types a very sneaky space that will cause some people problems if they are not paying close attention. It is: --defaults-file="my.ini"SPACE--init-file="........." Another thing, make sure you are in the actual directory, because even if you have mysqld.exe on the system path, it didn't work with me, I had to be in the actual directory as in the video.