Whenever you set up MySQL, you may have set up a username and password. When you connect, you connect like this:
mysql_connect(address of server, username, password)
You are not supplying a username and password, and it needs one.

    usng that method is for connecting through php,
    i am trying to connect through the mysql app

      Hi,

      if you use the mysql app then you also have to add the correct credentials, e.g.

      mysql -uuser -ppassword

        Hi,

        with a newly installed mysql user is root with password nothing.

        mysql -uroot would then be sufficient.

        If you compiled MySQL yourself you must also execute mysql_install_db to initialize the mysql database. But you shouldn't use that command if MySQL has already been set up because you would overwrite stuff otherwise.

          still isnt working 🙁

          right in msdos firstly i type what you have said

          mysql -uroot

          at that point my dos screen then looks like this

          mysql > mysql -uroot
          >

          expecting another command, i then type \c to clear the buffer
          then i type

          GRANT ALL PRIVILEGES ON . TO "user"@"%" IDENTIFIED BY "password" WITH
          GRANT OPTION;

          then my dos screen looks like this

          mysql> GRANT ALL PRIVILEGES ON . TO "comms"@"%" IDENTIFIED BY "jmplllmi" WITH
          GRANT OPTION;
          ERROR 1045: Access denied for user: '@' (Using password: NO)

          i dont know what i'm doing wrong if anything,

          please can you assist me further?!

          thanks very much Jon

            Hi,

            it might be a localhost/ip problem.

            Try the following:

            insert

            a) 127.0.0.1 localhost into your windows\hosts file (system32\drivers\etc\hosts on NT/2K/XP).
            b) try the following commands:

            mysql -uroot -h localhost
            mysql -uroot -h 127.0.0.1
            mysql -uroot -h <real ip address>
            mysql -uroot -h <hostname>

            We once had the problem that we couldnt connect to mysql with localhost but with the real hostname. Afterwards we added some records to the mysql.user table for localhost and after that we also were able to connect with -h localhost or with just mysql -uroot.

              hey again

              my hosts file has already got the line

              127.0.0.1 localhost

              within it

              and when i tried the commands you gave me

              mysql -uroot 127.0.0.1
              etc

              i still got the access message

                Try
                mysql -u root -p

                You will then be prompted for the password for root

                  on command prompt

                  mysqladmin -hlocalhost -uroot -p password newpassword

                    stupid thing

                    ok so i open up command prompt

                    i get the message

                    Welcome to the MySQL monitor. Commands end with ; or \g.
                    Your MySQL connection id is 30 to server version: 4.0.13-nt

                    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

                    mysql>

                    then i type in

                    mysqladmin -hlocalhost -uroot -p password <pass here>

                    if thats right :S

                    i also tried

                    mysqladmin -hlocalhost -uroot -p <pass here>
                    mysqladmin -hlocalhost -uroot -p <pass here> newpassword
                    mysqladmin -hlocalhost -uroot -p<pass here>
                    mysqladmin -hlocalhost -uroot -p<pass here> newpassword

                    and i editted my phpmyadmin config.inc to work with my password and it said

                    Access denied for user: 'root@127.0.0.1' (Using password: YES)

                    i dont know why this isnt work!

                    please could you send give me the exact code for adding a password to the default root user with the password as
                    thepass

                    thanks alot

                    Jon 🙁

                      you should not open the mysql prompt.

                      open a command prompt by typing

                      cmd

                      in start->run.
                      when the cmd-prompt opens
                      type

                      mysqladmin -hlocalhost -uroot -p password newpassword

                        when i enter

                        mysqladmin -hlocalhost -uroot -p password something

                        where "something" is the new password that i want

                        in the run command (start > run)

                        i am asked to open the the file "mysqladmin" with a program

                        although have not much experience with mysql i am sure this isnt meant to happen

                        instead of using that i then try

                        c:\webroot\mysql\bin\mysqladmin -hlocalhost -uroot -p password something

                        where "something" is still the password i want

                        it then asks me for a password after opening the mysqladmin.exe program i enter the password "something"
                        my computer bleeps and then mysqladmin.exe closes

                        before doing this it shows some text but closes before i have time to read it

                        please can you assist me as this is starting to be irritating, and i'm sure i am following your instructions correctly

                        Jon

                          Hi,

                          a different approach:

                          stop mysql
                          start the daemon manually skipping the grant tables

                          mysqld --skip-grant-tables

                          No connect to mysql with

                          mysql -h localhost mysql

                          and do something like

                          A)
                          use mysql;
                          update user set Password = PASSWORD('thepass') where User='root';
                          flush privileges;

                          Then quit mysql.

                          or 😎
                          mysqladmin -h hostname -u root password 'new password'
                          mysqladmin -h hostname flush-privileges

                          You might additionally need to insert a record with % or localhost as Host and root as user and fourteen 'Y' if you want to give root all rights.

                          INSERT INTO user ('localhost','root',PASSWORD('thepass'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');
                          FLUSH PRIVILEGES;

                          (you can do that with mysqladmin either)

                          Then stop mysql (you might need to kill it manually). Start mysql as usual and try to connect

                          mysql -h localhost -u root -p

                          and enter the new root password when asked for it.

                            ah finally the crisis is over

                            thanks very very much to all the peeps who helped out

                            now i can do things more safely!!

                            THANKS AGAIN 😃 🆒

                            Jon

                              What kind of windows are you running?

                              Open a command prompt by typing

                              command

                              or

                              command

                              then in the command prompt enter

                              c:\webroot\mysql\bin\mysqladmin -hlocalhost -uroot -p password something

                              Then you should be able to see the output.

                                i'm running windows xp, but i have the problem solved now

                                thanks anyway sdjensen

                                  Write a Reply...