mysql> create database test; ERROR 1006 (HY000): Can't create database 'test' (errno: 2)

后端 未结 4 2062
迷失自我
迷失自我 2021-01-05 14:32

I can\'t create a database after logging in mysql under my root account. Do I have to make an admin account to do so? Also, for some reason, my StartUp file didn\'t install

相关标签:
4条回答
  • 2021-01-05 15:03

    If you're on macosx and if you've system preference pane installed, that should show a message like

    the following directory is not owned by _mysql user - "/usr/local/msyql/data"
    

    Once you know that path you can do the following:

    sudo chown -R mysql:mysql /usr/local/mysql/data
    
    sudo chown -R mysql:mysql <path>
    
    0 讨论(0)
  • 2021-01-05 15:06

    As an additional resource, you can try two other things:

    1. Find out the data folder for your MySQL and 'chown' it so that mysql can write properly to it. For example, if your MySQL's data folder is /usr/local/mysql/data/, you can 'chown' it by typing up the command chown -R mysql:mysql /usr/local/mysql/data/

    2. If you have just installed your MySQL server, try restarting your computer. Sometimes the installer fails on giving proper file access to the program

    I hope that helps!

    0 讨论(0)
  • 2021-01-05 15:12

    You have one root user for several domains. Meaning you can connect and run queries on that database FROM the specified domains.

    If you want to only show one, give it '%' for the domain and remove all others, although that is not advised. Save the root user for run rights only from localhost, and create limited users for running queries from outside.

    As for test database error, it happens on fresh installs. Just reboot the mysql server(stop/start process) or the computer.

    Also, make sure you have full rights by doing

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'thedomainyourunfrom/localhost/%' WITH GRANT OPTION;
    

    this will give your root user full rights across all databases in the server

    osx manual http://dev.mysql.com/doc/mysql-macosx-excerpt/5.0/en/macosx-installation.html

    0 讨论(0)
  • 2021-01-05 15:23

    It might be problem with space. Follow this

    1. Check .err logs at /var/lib/mysql
    2. if the log says something like "[ERROR] Can't start server: can't create PID file: No space left on device"

    3. Check /var size by df -hk /var

    4. if used is 100% , then u have to find the files which is geting filled.

    5. find large file in /var by

      find /var/ -type f -size +100000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
    6. see which file you can delete and then restart the mysql process by

    7. /etc/init.d/mysql restart

    let me know if that worked :)

    0 讨论(0)
提交回复
热议问题