0

I followed the steps of this MS Guide and I managed to run a localdb and create a Testdb with this script:

CREATE DATABASE Test
ON
    (NAME='Test_DAT',
    FILENAME='/home/dlag/Documentos/Proyectos/BDtest/Test.mdf',
    SIZE=10,
    MAXSIZE=50,
    FILEGROWTH=5)
LOG ON
    (NAME='Test_Log',
    FILENAME='/home/dlag/Documentos/Proyectos/BDtest/Test.ldf',
    SIZE=5,
    MAXSIZE=25,
    FILEGROWTH=5);

GO
use Test;
GO

Time after, I try to create another db with the following script:

CREATE DATABASE BconDatos2
ON
    (NAME='BconDatos2_DAT',
    FILENAME='/home/dlag/Documentos/Proyectos/BDs/BiblioConDatos2/BconDatos2.mdf',
    SIZE=10,
    MAXSIZE=50,
    FILEGROWTH=5)
LOG ON
    (NAME='BconDatos2_Log',
    FILENAME='/home/dlag/Documentos/Proyectos/BDs/BiblioConDatos2/BconDatos2.ldf',
    SIZE=5,
    MAXSIZE=25,
    FILEGROWTH=5);

GO
use BconDatos2;

and I get this errors:

Msg 5123, Level 16, State 1, Line 4

AND SAYS(translated from Spanish):

The instruction CREATE FILE found OS error: 2(The system cannot find the file specified.) when trying to open or create the physical file. '/home/dlag/Documentos/Proyectos/BDs/BiblioConDatos2/BconDatos2.mdf'.

Msg 1802, Level 16, State 4, Line 4

(translated from Spanish):

CREATE DATABASE error. Can not create some of the files in the list. See related errors

Total execution time: 00:00:00.081

On both DB I'm in master and the path for mdf and ldf files are previously created.

It's strange because in the script of 'Test' DB I can make SELECTS for Tables, but when I run:

SELECT Name from sys.Databases

This database doesn't appear, but another empty DB created later appears.

Anyway on 'BconDatos2' DB script I can't create DataBases...

Problems with permissions on scripts?

  • 2
    Does the directory exist? Can you access /home/dlag/Documentos/Proyectos/BDs/BiblioConDatos2/? – Randi Vertongen Apr 25 at 12:23
  • Yes the path exists and I can access. – dlag Apr 25 at 13:44
  • You could take a look at this post regarding the permissions for the mssqluser and validate on the /home/dlag/Documentos/Proyectos/BDs/BiblioConDatos2 folder – Randi Vertongen Apr 25 at 14:04
0

The problem isn't solved, but I just donwloaded the software 'Azure Data Studio' developed for linux and I have been able to see that the tables were being created in master. It's seems this app works and is more convenient to me for learn msslq by now. So maybe we can close the post.

  • With Azure Data Studio I get the same error... I keep trying. – dlag Apr 25 at 15:45
0

Finally I solve it. The problem was about users permissions in the directory where T-SQL was going to create the file. I make the user 'mssql' who create the DB, owner of the folder where DB files are going to be placed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.